AnimationFrame.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. var root_1 = require('./root');
  3. var RequestAnimationFrameDefinition = (function () {
  4. function RequestAnimationFrameDefinition(root) {
  5. if (root.requestAnimationFrame) {
  6. this.cancelAnimationFrame = root.cancelAnimationFrame.bind(root);
  7. this.requestAnimationFrame = root.requestAnimationFrame.bind(root);
  8. }
  9. else if (root.mozRequestAnimationFrame) {
  10. this.cancelAnimationFrame = root.mozCancelAnimationFrame.bind(root);
  11. this.requestAnimationFrame = root.mozRequestAnimationFrame.bind(root);
  12. }
  13. else if (root.webkitRequestAnimationFrame) {
  14. this.cancelAnimationFrame = root.webkitCancelAnimationFrame.bind(root);
  15. this.requestAnimationFrame = root.webkitRequestAnimationFrame.bind(root);
  16. }
  17. else if (root.msRequestAnimationFrame) {
  18. this.cancelAnimationFrame = root.msCancelAnimationFrame.bind(root);
  19. this.requestAnimationFrame = root.msRequestAnimationFrame.bind(root);
  20. }
  21. else if (root.oRequestAnimationFrame) {
  22. this.cancelAnimationFrame = root.oCancelAnimationFrame.bind(root);
  23. this.requestAnimationFrame = root.oRequestAnimationFrame.bind(root);
  24. }
  25. else {
  26. this.cancelAnimationFrame = root.clearTimeout.bind(root);
  27. this.requestAnimationFrame = function (cb) { return root.setTimeout(cb, 1000 / 60); };
  28. }
  29. }
  30. return RequestAnimationFrameDefinition;
  31. }());
  32. exports.RequestAnimationFrameDefinition = RequestAnimationFrameDefinition;
  33. exports.AnimationFrame = new RequestAnimationFrameDefinition(root_1.root);
  34. //# sourceMappingURL=AnimationFrame.js.map