I need to call a function periodically with setInterval
and passing parameters to it. At the same time, I need to clear the interval inside the function that's being called when the mouse is moved.
So I'm trying this:
var timer = setInterval(function(x,y){ // When I use this, x and y are undefined.
/*
Code
*/
document.getElementById("wholeDocument").onmousemove=clearInterval(timer);
}, 50);
The idea is to know how to use setinterval with a clearInterval inside and being able to pass parameters.
I would appreciate any help.