Web APIs
cancelAnimationFrame()
Cancels an outstanding animation-frame callback request. It does not undo DOM modifications from callbacks that have already run. Multi-file example: save each listed file separately, then serve the entry over local HTTP in a browser. See the packaged fixture for the original files.
Formal Syntax & Structure
javascript syntaxjavascript
cancelAnimationFrame(requestId)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| requestId | number | Handle returned by requestAnimationFrame. |
Return Value
undefined
No return value.
Working Example
Example Snippetjavascript
// File: index.html<!doctype html><meta charset="utf-8"><title>Cancel frame</title><script>const id=requestAnimationFrame(()=>console.log("unexpected"));cancelAnimationFrame(id);requestAnimationFrame(()=>console.log("kept"));</script>