wokena wokena - 4 months ago 24
jQuery Question

How to get the direction of moving object in draggable plugin (jQuery)?

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 about this?

var start,stop;

    axis: "x",
    start: function(event, ui) {
        start = ui.position.left;
    stop: function(event, ui) {
        stop = ui.position.left;
        alert('has moved ' + ((start < stop) ? 'right':'left'))

crazy fiddle