+ 11
How do reset a javascript function
how to I reset a JavaScript function after execution
8 Respuestas
+ 11
alright how do I stop the function in another function
+ 9
I want to reset an animation in a move function
+ 2
try adding a pause or stop function..
+ 2
Whether you're using setInterval, then
var fps, render; // render is animating function and fps is frame per second.
var timer = setInterval(render, 1000/fps);
for stopping use,
clearInterval(timer);
for requestAnimationFrame,
var render = function(){
timer = window.requestAnimationFrame(render);
// write your animation logic below.
};
var timer = window.requestAnimationFrame(render);
to stop use
window.cancelAnimationFrame(timer);
+ 1
you know how u arranged all of them...take time and look at the animation ...even if u have to create functions start stop left right.
0
you would add in return 0;
0
or call the clearInterval()
0
Onclick events must call functions like: onclick="resetTimer();" with the parenthesis at the end. Some browsers may try to submit on button clicks if you don't define type="button". I didn't assume you wanted reset timer to stop the timer so I added a stop button.
copied