I have object (div-box), and it's draggable (I'm using jQuery). How I can get information which direction a visitor moved it? Example: User drag it to left down and I wanna know it, how?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
There is two answers to this question:
get direction in real time, namely no matter the starting position. For that you need to set and use
previousPosition
as follow:get direction after the drop, therefore using the starting position. For that you need to use the provided
originalPosition
as follow:Note: This code was written for and tested with jQuery 1.11.1
The original position is built into the ui.helper object.. You can just do:
You can do this in the start, drag, or stop event callbacks...
how about this?
crazy fiddle
Take a look at this page, Source code and Demo is available on this website :
http://www.coursesweb.net/jquery/jquery-ui-draggable-drag