jQuery UI : Before start draggable

前端 未结 4 1262

How to implement a before start event to have a change to change the position and place in the DOM of the draggable element before jQueryUI start to drag?

4条回答
  •  执笔经年
    2020-12-17 06:18

    For that I used mouseup and mousedown:

    var timeout;
    
    $('.draggable').mousedown(function() {
      $('#dragContainer').append($(this));
      $(this).css({
        top: 0,
        left: 0
      });
    });
    
    $('.draggable').draggable(); 
    

    I also used mouseup to reset the old parent and position if the mousedown was actually a click and not a drag.

    It would be nice to have a beforeStart event which work with the distance option but I didn't find it...

提交回复
热议问题