iOS上的JQ UI Draggable:在Taphold-Handler中启动拖动 [英] JQ UI Draggable on iOS: initiating dragging in taphold-handler

查看:107
本文介绍了iOS上的JQ UI Draggable:在Taphold-Handler中启动拖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的应用中,我们希望从一个列表拖放到另一个列表中.问题是,当列表中有很多项目时-元素可拖动时无法滚动.

In our app we want to drop from one list to over. Problem is, when there are many items in list - it's impossible to scroll when elements are dragable.

作为解决方法,我们希望禁用元素的可拖动性,并且仅在用户长按元素时才启用它.

As workaround we want to disable drag-ability of elements and enable it only when user makes a long tap on an element.

    $('li').bind('taphold', function (event, ui) {
        console.log('taphold');
        clearAll(); // clearing all other catched
        $(this).addClass('catched')
        $(this).draggable('enable');
    });

这是jsfiddle https://jsfiddle.net/nrxaqc34/10/

here is jsfiddle https://jsfiddle.net/nrxaqc34/10/

到目前为止,它仍然有效,但是用户需要再次点击才能拖动.如果用户可以在长按后立即开始拖动,那就太好了.

So far it works, but user needs to tap once more in order to drag. And would be nice if user could start dragging right after long tap.

此处的答案 https://stackoverflow.com/a/9922048/582727 在iOS上不起作用.

This answer here https://stackoverflow.com/a/9922048/582727 doesn't work on iOS.

也许有人有主意.

推荐答案

使用延迟选项是否有意义? http://api.jqueryui.com/draggable/#option-delay

Does it make sense to use delay option? http://api.jqueryui.com/draggable/#option-delay

$("li").draggable().draggable( "option", "delay", 2000);

提琴: https://jsfiddle.net/dob3uegj/

jqueryui-touch-punch( http://touchpunch.furf.com/)已添加到小提琴中,用于智能手机模拟: https://jsfiddle.net/dob3uegj/1/

jqueryui-touch-punch (http://touchpunch.furf.com/) added to fiddle for smartphone simulations: https://jsfiddle.net/dob3uegj/1/

这篇关于iOS上的JQ UI Draggable:在Taphold-Handler中启动拖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆