window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); };})();function backTop(){ var scrollingElement = document.scrollingElement || document.documentElement || document.body; scrollingElement.scrollTop = scrollingElement.scrollTop - 10; console.log(scrollingElement.scrollTop == 0 ) if( scrollingElement.scrollTop == 0 ){ cancelAnimationFrame(aaa) } requestAnimFrame(backTop)};var aaa;function aa() { aaa = requestAnimFrame(backTop)}目前開始了不知道是怎么才能停下的。。
請問cancelAnimationFrame的使用方法
慕桂英3389331
2018-12-21 19:14:53