Namespace: Timers:requestAnimationFrame

Timers:requestAnimationFrame

Source:

Methods

requestAnimationFrame(callback) → {Number}

This is a simple streamlined, vendor-cascading version of window.requestAnimationFrame with a timeout fallback in case the functionality is missing from the browser.

Parameters:
Name Type Description
callback function

the code to execute once the browser has assigned an execution slot for it

Source:
See:
Throws:

error if callback is not a function

Returns:
either the id of the requestAnimationFrame or the internal timeout, both are cancellable via cancelAnimationFrame
Type
Number
Example
const requestId = requestAnimationFrame(function(){ window.body.style.opacity = 0; });