Here, requestAnimationFrame() came into the picture. Basically, requestAnimationFrame() method easily syncs in with your browser timings and generate a call to perform the specific animation before the actual loading of the screen. Further, it also slows down its process when the animation is actually not in the use thus saving resources.
window.requestAnimationFrame( callback );
Parameter: This method accepts single parameter as mentioned above and described below:
- callback: Unless you want the animation to stop, you should write the callback function so that it calls itself so that a request to the next frame is made. Callback function takes timestamp or simply a time value at which it should start executing.
Return Values: This method returns a non zero long integer value that acts as a unique identity for the animation entry in callback function.
Below examples illustrate the requestAnimationFrame() method in Web API:
Supported Browsers: The browsers supported by Window.requestAnimationFrame() Method are listed below:
- Google Chrome 23.0
- Internet Explorer 10.0
- Firefox 11.0
- Opera 10.0
- Safari 6.1
- HTML | Window createPopup() Method
- HTML | DOM Window stop() Method
- HTML | window matchMedia() Method
- HTML | Window scrollBy() method
- HTML | Window resizeBy() Method
- HTML | Window atob( ) Method
- HTML | DOM Window btoa() Method
- HTML | Window alert( ) Method
- HTML | Window resizeTo() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.