Your Search Results

    Window.cancelAnimationFrame

    « Window

    This is an experimental technology
    Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

    Summary

    Cancels an animation frame request previously scheduled through a call to window.requestAnimationFrame().

    Syntax

    window.cancelAnimationFrame(requestID);
    

    Note: Prior to Firefox 23, the function is vendor-prefixed window.mozCancelAnimationFrame(). See the compatibility table, below, for other browser implementations.

    Parameters

    requestID
    The ID value returned by the call to window.requestAnimationFrame() that requested the callback.

    Examples

    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().
    
    function step(timestamp) {
      var progress = timestamp - start;
      d.style.left = Math.min(progress/10, 200) + "px";
      if (progress < 2000) {
        requestAnimationFrame(step);
      }
    }
    var myReq = requestAnimationFrame(step);
    
    window.cancelAnimationFrame(myReq);
    

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
    Basic support 21.0 webkit
    24.0
    11.0 (11.0) moz
    23.0
    10 ? 6.0 webkit
    unprefixed in nightlies
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
    Basic support ? ? 11.0 (11.0) moz
    23.0
    ? ? ?

    Specification

    See also

    Document Tags and Contributors

    Last updated by: teoli,
    Hide Sidebar