Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. Web API
  3. Window
  4. window.cancelAnimationFrame()

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

window.cancelAnimationFrame()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

window.cancelAnimationFrame() メソッドは、以前にwindow.requestAnimationFrame() の呼び出しによってスケジュールされたアニメーションフレームリクエストをキャンセルします。

構文

js
cancelAnimationFrame(requestID)

引数

requestID

コールバックをリクエストしたwindow.requestAnimationFrame() の呼び出しによって返された ID 値。

返値

なし (undefined)。

js
const requestAnimationFrame =  window.requestAnimationFrame ||  window.mozRequestAnimationFrame ||  window.webkitRequestAnimationFrame ||  window.msRequestAnimationFrame;const cancelAnimationFrame =  window.cancelAnimationFrame || window.mozCancelAnimationFrame;const start = Date.now();let myReq;function step(timestamp) {  const progress = timestamp - start;  d.style.left = `${Math.min(progress / 10, 200)}px`;  if (progress < 2000) {    // requestAnimationFrame を呼び出すたびに requestId を更新することが重要です    myReq = requestAnimationFrame(step);  }}myReq = requestAnimationFrame(step);// キャンセル処理は、最後の requestId を使用しますcancelAnimationFrame(myReq);

仕様書

Specification
HTML
# animationframeprovider-cancelanimationframe

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp