not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
971 B

  1. (function(window) {
  2. var lastTime = 0;
  3. var vendors = ['ms', 'moz', 'webkit', 'o'];
  4. for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
  5. window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
  6. window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
  7. }
  8. if (!window.requestAnimationFrame){
  9. window.requestAnimationFrame = function(callback, element) {
  10. var currTime = new Date().getTime();
  11. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  12. var id = window.setTimeout(function() { callback(currTime + timeToCall); },
  13. timeToCall);
  14. lastTime = currTime + timeToCall;
  15. return id;
  16. };
  17. }
  18. if (!window.cancelAnimationFrame){
  19. window.cancelAnimationFrame = function(id) {
  20. clearTimeout(id);
  21. };
  22. }
  23. }(this));