Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Window: cancelAnimationFrame() method

BaselineWidely available

Thewindow.cancelAnimationFrame() method cancels ananimation frame request previously scheduled through a call towindow.requestAnimationFrame().

Syntax

js
cancelAnimationFrame(requestID)

Parameters

requestID

The ID value returned by the call towindow.requestAnimationFrame()that requested the callback.

Return value

None (undefined).

Examples

js
const start = document.timeline.currentTime;let myReq;function step(timestamp) {  const progress = timestamp - start;  d.style.left = `${Math.min(progress / 10, 200)}px`;  if (progress < 2000) {    // it's important to update the requestId each time you're calling requestAnimationFrame    myReq = requestAnimationFrame(step);  }}myReq = requestAnimationFrame(step);// the cancellation uses the last requestIdcancelAnimationFrame(myReq);

Specifications

Specification
HTML
# animationframeprovider-cancelanimationframe

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp