如何在“绑定(bind)”函数中使用 jQuery UI 可拖动选项?使用标准 draggable()
函数无法满足我的要求。
谢谢!
$('a#dragthis')
.bind('dragstart', function(e) {
isDragging = true;
})
.bind('drag', function(e) {
var x = e.pageX;
var y = e.pageY;
console.log(x + "|" + y);
motivationIsWorking(x, y);
})
.bind('dragend', function(e) {
isDragging = false;
motivationStopped();
unmotivateUser();
});
最佳答案
Draggable 具有回调函数来准确执行您正在寻找的操作:
http://jqueryui.com/draggable/
http://api.jqueryui.com/draggable/#event-stop
所以代替这个
.bind('dragend', function(e) {
isDragging = false;
motivationStopped();
unmotivateUser();
});
这样做
$(element).draggable({
stop:function( event, ui ) {
isDragging = false;
motivationStart();
remotivateUser();
}
});
关于jQuery UI——绑定(bind)函数中的可拖动选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10808269/