(solved) jQuery click and drag/scroll window: jagged movement
- by Josh
Edit: derp, using pageX/Y instead of clientX/Y -- apparently scrollBy expects input with that offset rather than the other. Jaggy movement gone.
I am getting jagged movement when doing small scroll increments using the following bindings. Can anyone point me in the right direction for how to smooth this out? FYI, its intermittent. It seems like, if I click and hold for a second, then drag at a decent speed there are no problems.
Edit:
What the hell? I get this output on debug... obvious jog backwards and forwards. This will happen in succession and seems to have no correlation with the mouse, other than the mouse is moving.
x 398 : 403
y 374 : 377
x 403 : 399
y 377 : 374
x 399 : 404
y 374 : 377
Josh
sococo.client.panMap = function(e){
e.preventDefault();
var movex = sococo.client.currX - e.pageX ;
var movey = sococo.client.currY - e.pageY;
console.log( sococo.client.currX +" : " + e.pageX );
window.scrollBy(movex,movey);
sococo.client.currY = e.pageY;
sococo.client.currX = e.pageX;
}
$(document).mousedown( function(e){
e.preventDefault();
sococo.client.currX = e.pageX;
sococo.client.currY = e.pageY;
$(document).bind( "mousemove", sococo.client.panMap );
});
$(document).mouseup( function(e){
e.preventDefault();
$(document).unbind( "mousemove", sococo.client.panMap );
});