美文网首页
requestAnimationFrame

requestAnimationFrame

作者: 一沭丶 | 来源:发表于2019-01-03 15:26 被阅读8次

    向下兼容

    window.requestAnimationFrame=window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        function( callback ){
            //为了使setTimteout的尽可能的接近每秒60帧的效果
            window.setTimeout(callback,1000/60);
        }
     
    window.cancelAnimationFrame=window.cancelAnimationFrame ||
        Window.webkitCancelAnimationFrame ||
        window.mozCancelAnimationFrame ||
        window.msCancelAnimationFrame ||
        window.oCancelAnimationFrame ||
        function( id ){
            //为了使setTimteout的尽可能的接近每秒60帧的效果
            window.clearTimeout( id );
        }
    

    相关文章

      网友评论

          本文标题:requestAnimationFrame

          本文链接:https://www.haomeiwen.com/subject/henfrqtx.html