How can I change the revert speed of a jquery draggable div

时间:2015-07-31 20:49:14

标签: jquery draggable droppable revert

I have written a workable version of Solitaire using Jquery's draggable and droppable functions. To capture all the cards I'm dragging I drag the div they reside in. After the drop routine the div reverts to its original position on the board. The problem is that the card(s) are changed in the drop routine so you see the changed card(s) floating back across the board to the original position.

I can hide the helper (which is the original image) with ui.helper.hide() and re-show it with ui.helper.show(), but there's still a delay time - the time it takes the div to move back.

I need to either change the revert time to 0 or force the div back to its original position to remove the delay, and I can't seem to figure out how to do that.

Can anyone help me?

1 个答案:

答案 0 :(得分:3)

您可以使用revertDuration

  

恢复动画的持续时间,以毫秒为单位。如果revert选项为false,则忽略。

$( ".selector" ).draggable({
  revertDuration: 0
});