How do I control a window by mouse movement in javascript?? I mean the page should auto scroll on moving the mouse.
Asked
Active
Viewed 177 times
1
-
http://stackoverflow.com/questions/6518600/scroll-window-when-mouse-moves – Salt Hareket Apr 25 '12 at 08:03
-
yeah, do google before asking questions here, though I have worked with parallax before, the code I pasted below is what I got on googling. – gopi1410 Apr 25 '12 at 08:06
1 Answers
0
This can be done using parallax like in this http://www.franckmaurin.com/the-parallax-effects-with-jquery/
You are not actually controlling a window but divs.
Here is a sample basic code:
// Variables for current position
var x, y;
function handleMouse(e)
{
if (x && y)
{
window.scrollBy(e.clientX - x, e.clientY - y);
}
x = e.clientX;
y = e.clientY;
}
document.onmousemove = handleMouse;

gopi1410
- 6,567
- 9
- 41
- 75