animationFrameProvider.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. var __read = (this && this.__read) || function (o, n) {
  3. var m = typeof Symbol === "function" && o[Symbol.iterator];
  4. if (!m) return o;
  5. var i = m.call(o), r, ar = [], e;
  6. try {
  7. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  8. }
  9. catch (error) { e = { error: error }; }
  10. finally {
  11. try {
  12. if (r && !r.done && (m = i["return"])) m.call(i);
  13. }
  14. finally { if (e) throw e.error; }
  15. }
  16. return ar;
  17. };
  18. var __spreadArray = (this && this.__spreadArray) || function (to, from) {
  19. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
  20. to[j] = from[i];
  21. return to;
  22. };
  23. Object.defineProperty(exports, "__esModule", { value: true });
  24. exports.animationFrameProvider = void 0;
  25. var Subscription_1 = require("../Subscription");
  26. exports.animationFrameProvider = {
  27. schedule: function (callback) {
  28. var request = requestAnimationFrame;
  29. var cancel = cancelAnimationFrame;
  30. var delegate = exports.animationFrameProvider.delegate;
  31. if (delegate) {
  32. request = delegate.requestAnimationFrame;
  33. cancel = delegate.cancelAnimationFrame;
  34. }
  35. var handle = request(function (timestamp) {
  36. cancel = undefined;
  37. callback(timestamp);
  38. });
  39. return new Subscription_1.Subscription(function () { return cancel === null || cancel === void 0 ? void 0 : cancel(handle); });
  40. },
  41. requestAnimationFrame: function () {
  42. var args = [];
  43. for (var _i = 0; _i < arguments.length; _i++) {
  44. args[_i] = arguments[_i];
  45. }
  46. var delegate = exports.animationFrameProvider.delegate;
  47. return ((delegate === null || delegate === void 0 ? void 0 : delegate.requestAnimationFrame) || requestAnimationFrame).apply(void 0, __spreadArray([], __read(args)));
  48. },
  49. cancelAnimationFrame: function () {
  50. var args = [];
  51. for (var _i = 0; _i < arguments.length; _i++) {
  52. args[_i] = arguments[_i];
  53. }
  54. var delegate = exports.animationFrameProvider.delegate;
  55. return ((delegate === null || delegate === void 0 ? void 0 : delegate.cancelAnimationFrame) || cancelAnimationFrame).apply(void 0, __spreadArray([], __read(args)));
  56. },
  57. delegate: undefined,
  58. };
  59. //# sourceMappingURL=animationFrameProvider.js.map