I have a draggable element $myElement with revert: true. Now specifying revertDuration will determine the time the reverting animation will take to complete.
My problem is that the speed of the animation will vary greatly depending on how far $myElement is dropped from the original location.
Is there a way of specifying the speed of the animation (as opposed to the total time)?
What you need is
positionplugin for jQuery UI found here: http://jqueryui.com/demos/position/You can get offset of the draggable element. Or simply use:
Solution which comes to my mind:
Save position of the element when
startevent of draggable object is fired. Then do the same when ‘stop’ event occurs andanimatethe element back to starting offset. The difference in offsets is a line which its length will be proportional to the time required to travel back.You can try to set revert duration when
stopevent is called to avoidanimatebut I don’t know if it make it before revert animation.