Cancels an animation frame request previously scheduled through a call to window.requestAnimationFrame()
.
window.cancelAnimationFrame(requestID);
requestID
window.requestAnimationFrame()
that requested the callback.var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame; var start = window.mozAnimationStartTime; // Only supported in FF. Other browsers can use something like Date.now(). 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); cancelAnimationFrame(myReq);
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | 23
|
10 | 15 | 6.1
|
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | 23
|
33 | 7.1 | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/window/cancelAnimationFrame