gpt4 book ai didi

javascript - 拖入 gridster 之前的延迟

转载 作者:行者123 更新时间:2023-12-03 12:41:33 24 4
gpt4 key购买 nike

我在项目中使用gridster.net,但遇到了问题。

我试图让小部件仅在单击后按住鼠标一秒钟后才开始拖动。我正在使用下一个代码:

$(".gridster .gs-w").on('mousedown', function(e) {
gridsterObj.disable();
dragTimeout = setTimeout(function() {
gridsterObj.enable();
}, 500);
}).bind('mouseup mouseleave', function() {
clearTimeout(dragTimeout);
});

但是没有成功。看来我必须调用开始拖动的函数,例如gridsterObj.on_start_drag.call(gridsterObj, e, ui);,但是我在哪里可以获得UI对象?它在 gridster 代码中随处使用,但我找不到它创建的位置。看来它是 jquery UI 对象。我该如何创建它?

最佳答案

您应该能够将 UI 对象引用为 $.uiwindow.jQuery.ui

所以你的代码应该如下所示:

$(".gridster .gs-w").on('mousedown', function(e) {
gridsterObj.disable();
dragTimeout = setTimeout(function() {
gridsterObj.enable();
gridsterObj.on_start_drag.call(gridsterObj, $.ui);
}, 500);
}).bind('mouseup mouseleave', function() {
clearTimeout(dragTimeout);
});

关于javascript - 拖入 gridster 之前的延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23509120/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com