【问题标题】:jQuery UI -- Draggable options in bind functionjQuery UI -- 绑定函数中的可拖动选项
【发布时间】:2012-05-29 23:49:48
【问题描述】:

如何在“绑定”函数中使用 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();
    });

【问题讨论】:

    标签: jquery jquery-ui draggable


    【解决方案1】:

    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();
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2018-04-14
      • 2015-10-30
      • 1970-01-01
      • 2012-10-29
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多