为 jQuery UI Draggable() 设置超时以防止锁定效果

发布于 2024-07-13 07:24:05 字数 317 浏览 5 评论 0原文

我正在使用draggable(),但有时draggable()似乎会产生锁定效果,即使释放鼠标按钮后拖动效果仍然存在。 一旦发生这种情况,唯一的解决办法就是刷新页面,这对于基于 ajax 的网站来说是一种糟糕的方法。

因此,使用 UI 文档 我试图找到一种设置超时的方法当拖动开始时,如果在x秒内拖动没有完成,则将调用dragstop事件。

我想这并不难,但到目前为止我还无法实现。 任何帮助将非常感激。

I'm using draggable(), but occasionally the draggable() seems to create a locking effect where the dragging effect persists even after the mouse button is released. Once this happens, the only fix is to refresh the page, which is a terrible way to go for an ajax-based site.

So using the UI docs I'm trying to figure out a way to set a timeout when dragging starts, so that if the dragging isn't finished within x seconds, then the dragstop event will be called.

I imagine this wouldn't be hard, but I haven't been able to implement it so far. Any help would be very much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天涯沦落人 2024-07-20 07:24:05

我不想建议这个,但我会花更多的时间试图理解为什么你不能让draggable正常工作,而不是询问在创可贴修复中进行黑客攻击......

i hate to suggest this, but I'd spend a little more time trying to understand out WHY you can't get draggable to work properly rather than asking about hacking in a bandaid fix...

她说她爱他 2024-07-20 07:24:05

尝试这样的事情:

var stopDrag = function() {
    $('.selector').draggable('destroy');
}

$('.selector').draggable({
    start: function(event, ui) { 
        setInterval(stopDrag, 2000); 
    }
});

Try something like this:

var stopDrag = function() {
    $('.selector').draggable('destroy');
}

$('.selector').draggable({
    start: function(event, ui) { 
        setInterval(stopDrag, 2000); 
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文