Dragging an element with mousemove handler stops tracking if mouse moves too quickly

2.3k Views Asked by At

I've set up a mousemove handler to drag an element. However, if you move the cursor too quickly, it loses track of the element and doesn't move it anymore until you bring your cursor back over the element.

Here's a JSFiddle demo.

Why does it do that?

 $this.on("mousemove.partmove touchmove", function(e){
     e.preventDefault();
     var moveL = e.clientX; 
     var moveT = e.clientY;
     console.log("mov " + (moveT-vOffset) );
     $this.css({"left": moveL-hOffset, "top": moveT-vOffset});
 });
1

There are 1 best solutions below

0
On

i had the same problem. the only thing that i've done was that i define mousemove event for its parent element. that way it can tracks the location of pointer even if you move it fast.