--- title: Window.cancelAnimationFrame() slug: Web/API/Window/cancelAnimationFrame tags: - API - Animation - DOM - Experimentell - Méthode translation_of: Web/API/Window/cancelAnimationFrame ---
Stopt eine vorher durch {{domxref("window.requestAnimationFrame()")}} geplante Animation.
window.cancelAnimationFrame(requestID);
requestIDvar requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
var start = window.mozAnimationStartTime; // Nur unterstützt in FF. Andere Browsers können zB Date.now() benutzen.
var myReq;
function step(timestamp) {
var progress = timestamp - start;
d.style.left = Math.min(progress/10, 200) + "px";
if (progress < 2000) {
myReq = requestAnimationFrame(step);
}
}
myReq = requestAnimationFrame(step);
window.cancelAnimationFrame(myReq);
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
{{Compat("api.Window.cancelAnimationFrame")}}