Here is a working fork of your fiddle http://jsfiddle.net/Boolean/b6TUf/4/
Your version did not work for the following reasons.
- You needed to include the JQueryUI framework.
- You were not setting
prevXPos = event.pageX;
as I have in my first answer withprevPos = e.clientX;
. This needs to be done after the direction is set to help keep track of the current direction. - You were not instantiating the
dirX
variable. - I have targeted ID's rather than classes. It would have worked without but it would not be very optimised.
- It was spinning many times because you were instantiating the tweens inside the draggable function. This meant that new tweens were being created every times you dragged.
- You needed to reset the
prevXPos = event.pageX;
on drag start.
Hope this helps :)