window.cancelAnimationFrame()

window.cancelAnimationFrame() 메소드는 이전에 window.requestAnimationFrame() 을 호출하여 스케줄된 애니메이션 프레임 요청을 취소합니다.

구문

window.cancelAnimationFrame(requestID);

Parameters

requestID
요청된 콜백 window.requestAnimationFrame() 을 호출하여 반환된 ID 값.

예시

var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
                            window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;

var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;

var start = window.mozAnimationStartTime;  // Firefox 에서만 지원됨. 다른 브라우저에서는 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);

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
cancelAnimationFrameChrome Full support YesEdge Full support 12Firefox Full support 23
Full support 23
No support 11 — 23
Prefixed
Prefixed Implemented with the vendor prefix: moz
IE Full support 10Opera Full support 15Safari Full support 6.1
Full support 6.1
No support 6 — 6.1
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 23
Full support 23
No support 14 — 23
Prefixed
Prefixed Implemented with the vendor prefix: moz
Opera Android Full support 14Safari iOS Full support 7Samsung Internet Android Full support Yes

Legend

Full support  
Full support
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

명세

함께 보기