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 wit开发者_StackOverflow中文版hout 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.
精彩评论