+ 11

How do reset a javascript function

how to I reset a JavaScript function after execution

12th Dec 2017, 9:32 AM
King Frankostein®
King Frankostein® - avatar
8 odpowiedzi
+ 11
alright how do I stop the function in another function
12th Dec 2017, 9:46 AM
King Frankostein®
King Frankostein® - avatar
+ 9
I want to reset an animation in a move function
12th Dec 2017, 9:43 AM
King Frankostein®
King Frankostein® - avatar
+ 2
try adding a pause or stop function..
12th Dec 2017, 9:45 AM
Android Boi
Android Boi - avatar
+ 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);
19th Feb 2018, 6:04 AM
Vikash Pal
Vikash Pal - avatar
+ 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.
12th Dec 2017, 9:48 AM
Android Boi
Android Boi - avatar
0
you would add in return 0;
12th Dec 2017, 9:39 AM
Android Boi
Android Boi - avatar
0
or call the clearInterval()
12th Dec 2017, 9:42 AM
Android Boi
Android Boi - avatar
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
12th Dec 2017, 9:42 AM
Android Boi
Android Boi - avatar