Basically, I’m trying to have an “auto scroll” option for my site, I’ve got the basis of it working, although it doesn’t re scroll back if you move the mouse back to the left rather than the right.
I’ve been at this for over 3 hours now, no luck what so ever searching the net!
Here’s what I have:
$(document).mousemove(function(e){
window.mouseXPos = e.pageX;
window.mouseYPos = e.pageY;
var height = $(window).height() /2;
if (window.mouseYPos < height){
$('body,html').stop().animate({
scrollTop: window.mouseYPos
},10 );
}
else{
$('body,html').stop().animate({
scrollTop: -window.mouseYPos
},10 );
}
});
Try to delay your animation after 100ms where the mouse is not moving to avoid the new animation starts after each mouse pixel moving