Web APIs
requestAnimationFrame()
Requests a one-shot rendering callback receiving a timestamp. The request ID can cancel a pending callback.
Formal Syntax & Structure
javascript syntaxjavascript
requestAnimationFrame(callback)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| callback | function | Frame callback accepting a timestamp. |
Return Value
number
Request ID.
Working Example
Example Snippetjavascript
(async () => {const t=await new Promise(resolve=>requestAnimationFrame(resolve));console.log(typeof t,Number.isFinite(t));})()