当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery droppable on deactivate find out if an element was successfully dropped

问题描述:

Is there any way to pass to deactivate: whether an element was dropped or not?

I want to stop an animation if the element wasn't dropped, but was let go (ie: deactivate without drop), but I want it to carry on if the element was dropped correctly.

Thanks

网友答案:

I'm not sure if this is the best way, but it works:

I'm assuming you want to do this multiple times i.e. Keep animating while it is dropped correctly and if it is dragged out again and not dropped then cut the animation.

I would start by adding a parameter to the item being dragged which would indicate whether it is inside the target or not. e.g. var over_target = false;

When activate is called start the animation.

If the over event occurs the set over_target = true; if out event occurs then set over_target = false;

When deactivate is called you only need to check if over_target == false then stop the animation.

分享给朋友:
您可能感兴趣的文章:
随机阅读: