CodeKing
Jan 1 2008, 10:56 PM
I'm making a script that detects mouse movements. But the only way I have found out to do this is onmousemove. So I have onmousemove set a variable containing the mouse coordinates. Every 500 milliseconds, another function runs that processes the mouse movements and decides what to do. But, onmousemoves runs whenever the mouse moves. If the mouse is moving full speed thats several times a second. Is there a better way to do this?
Christian J
Jan 2 2008, 06:19 PM
Why not let the timer to run the script regardless of wether the mouse has moved or not?
CodeKing
Jan 2 2008, 06:27 PM
i was going to do
function every500milliseconds() {
getMouseCoord();
}
but i can't seem to get mouse coordinates without an event handler from onmousemove.
So I do this:
window.onmousemove = function(e) {
coord = getMouseCoord(e)
//process mouse coordinates
}
function every500milliseconds() {
//process mouse coordinates
}
I've tried window.event and event. Event works only in IE and window.event doesn't work at all. So I have to use mousemove for the event handler.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.