如何捕获拖动事件的任何结束

How to catch any end of a drag event?

本文关键字:任何 结束 事件 何捕获 拖动      更新时间:2023-09-26

>问题:有一个设置为draggable的元素。当用户完成拖动元素以向其附加函数时,需要捕获所有情况。到目前为止,我使用mouseleavemouseup但仍然错过了一些情况。这是代码:

handleMaxEl
    .css('left', scope.max * rangeEl.width() / valuesNumber)
    .draggable({
        containment: '.range-holder',
        axis: 'x'
    })
    .on('drag', handlesHandler)
    .on('mouseup mounseleave', positionHandles);

有什么帮助吗?

 $( "#draggable" ).draggable({
      start: function() {
        counts[ 0 ]++;
        updateCounterStatus( $start_counter, counts[ 0 ] );
      },
      drag: function() {
        counts[ 1 ]++;
        updateCounterStatus( $drag_counter, counts[ 1 ] );
      },
      stop: function() {
        counts[ 2 ]++;
        updateCounterStatus( $stop_counter, counts[ 2 ] );
      }
    });

有拖动、开始和停止 http://jqueryui.com/draggable/#events 的事件

可以使用

可拖动stop回调,并在拖动停止时触发。

$( ".selector" ).draggable({
stop: function( event, ui ) {}
});

在此处查看更多内容。