Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web-APIs
  3. Window
  4. cancelAnimationFrame()

Dieser Inhalt wurde automatisch aus dem Englischen übersetzt, und kann Fehler enthalten.Erfahre mehr über dieses Experiment.

View in EnglishAlways switch to English

Window: Methode cancelAnimationFrame()

Baseline Widely available

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

Die Methodewindow.cancelAnimationFrame() storniert eine Animationsrahmenanfrage, die zuvor durch einen Aufruf vonwindow.requestAnimationFrame() geplant wurde.

Syntax

js
cancelAnimationFrame(requestID)

Parameter

requestID

Der ID-Wert, der durch den Aufruf vonwindow.requestAnimationFrame() zurückgegeben wurde, der den Rückruf angefordert hat.

Rückgabewert

Keiner (undefined).

Beispiele

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);

Spezifikationen

Specification
HTML
# animationframeprovider-cancelanimationframe

Browser-Kompatibilität

Siehe auch

Help improve MDN

Learn how to contribute Diese Seite wurde automatisch aus dem Englischen übersetzt.

[8]ページ先頭

©2009-2026 Movatter.jp