Canceling requestAnimationFrame() #
If you assign your requestAnimationFrame() methodto a variable, you can use the cancelAnimationFrame() methodto cancel it before it runs. // Setup the animation var animation = window. requestAnimationFrame(function ()