Search code examples
jquery-uianimationjquery-ui-sortablerevert

jQuery UI sortable revert option - enable dragging during animation


I currently have a jQuery UI sortable element and I set the revert option to 1000 for a smooth but not too fast animation. While the animation works fine, it seems like I cannot drag during the animation.

I made a simplified version on jsFiddle: http://jsfiddle.net/bA7Dk/. When dragging the 1 somewhere and releasing the mouse, it isn't until the animation has completed that you can drag the 2.

Is there any way to enable dragging during the animation?


Solution

  • I sorted it out by altering jquery.ui.sortable.js:

    • Add this as an property to $.widget (where all functions are added as well):

      revertingElem: $(),
      
    • Modify inside _mouseStop:

      self.reverting = true
      

      to

      self.reverting = true           
      this.revertingElem = $(this.helper);
      
    • Modify inside _mouseCapture:

      return false;     (the first occurence)
      

      to

      $(this.revertingElem).stop(true, true);