Stopping Your Animation Loop
We'll cover the following...
Once your requestAnimationFrame
loop starts running, rarely will you ever need to tell it to stop. If you do need to stop your animation loop from doing unnecessary work, you can do something like the following:
Press + to interact
var running = true;function animate() {if (running) {// do animation or drawing stuff}requestAnimationFrame(animate);}
If your running
variable ...