-2

I've been looking about the mousemove() and mousedown() methods on the docs @ jQuery's official but didn't managed to come up with a simple solution to listen and do something when the mouse-dragging left/right event happens.

Thank you!

Julian Abal
  • 49
  • 2
  • 8

1 Answers1

0

The obvious starting place is http://api.jqueryui.com/draggable/

Take a look at this fiddle http://jsfiddle.net/MMcYT/ (from How to get the direction of moving object in draggable plugin (jQuery)?) which I think solves your problem

var start,stop;

$("#draggable2").draggable({
    axis: "x",
    start: function(event, ui) {
        start = ui.position.left;
    },
    stop: function(event, ui) {
        stop = ui.position.left;
        alert('has moved ' + ((start < stop) ? 'rigth':'left'))
    }
});

(Credit to @Reigel)

Community
  • 1
  • 1
jcuenod
  • 55,835
  • 14
  • 65
  • 102