'How to catch any end of a drag event?

Problem: having an element that set as draggable. Need to catch all cases when user finished to drag the element to attach a function to it. So far I use mouseleave and mouseup but still miss some cases. Here is the code:

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

Any help?



Solution 1:[1]

You can use stop callback of draggable ,And is Triggered when dragging stops.

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

See more here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Runcorn