window.requestAnimationFrameRate()
Sometimes you need to render at a specific frame rate.
When you use window.requestAnimation
browsers make their best to call your function as fast as possible.
window.requestAnimationFrameRate()
creates an intermediate function with the same signature as window.requestAnimation
but being called at a specified frame rate.
Basic usage
// First you create a function with a specified frame rate, here 25 frames per secondvar requestAnimationFrameAt25FPS = window // The render() function will be called at 25 frames per second{ ; //Do anything you want every 25 frames per second} ;
Cancel usage
// Similar piece of code as in previous examplevar requestAnimationFrameAt25FPS = window requestID;{ requestID = ; //Do anything you want every 25 frames per second} requestID = ; // Any time a request is cancelablewindow