requestAnimationFrame.js后续学习

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了requestAnimationFrame.js后续学习相关的知识,希望对你有一定的参考价值。

(function() {
  var lastTime = 0;
  var vendors = [‘webkit‘, ‘moz‘];
  for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
    window.requestAnimationFrame = window[vendors[x] + ‘RequestAnimationFrame‘];
    window.cancelAnimationFrame = window[vendors[x] + ‘CancelAnimationFrame‘] ||    // name has changed in Webkit
      window[vendors[x] + ‘CancelRequestAnimationFrame‘];
  }

  if (!window.requestAnimationFrame) {
    window.requestAnimationFrame = function(callback, element) {
      var currTime = new Date().getTime();
      var timeToCall = Math.max(0, 16.7 - (currTime - lastTime));
      var id = window.setTimeout(function() {
        callback(currTime + timeToCall);
      }, timeToCall);
      lastTime = currTime + timeToCall;
      return id;
    };
  }
  if (!window.cancelAnimationFrame) {
    window.cancelAnimationFrame = function(id) {
      clearTimeout(id);
    };
  }
}());

 

以上是关于requestAnimationFrame.js后续学习的主要内容,如果未能解决你的问题,请参考以下文章

关机后Arduino死机

计数单位

Linux下设置Swap后, 重启后设置失效 怎么处理?

为啥电脑更新系统后这么卡?

ug后处理无法输入中括号

插入后触发多次插入后无法正常工作