AnimationFrameScheduler.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.AnimationFrameScheduler = void 0;
  19. var AsyncScheduler_1 = require("./AsyncScheduler");
  20. var AnimationFrameScheduler = (function (_super) {
  21. __extends(AnimationFrameScheduler, _super);
  22. function AnimationFrameScheduler() {
  23. return _super !== null && _super.apply(this, arguments) || this;
  24. }
  25. AnimationFrameScheduler.prototype.flush = function (action) {
  26. this._active = true;
  27. var flushId;
  28. if (action) {
  29. flushId = action.id;
  30. }
  31. else {
  32. flushId = this._scheduled;
  33. this._scheduled = undefined;
  34. }
  35. var actions = this.actions;
  36. var error;
  37. action = action || actions.shift();
  38. do {
  39. if ((error = action.execute(action.state, action.delay))) {
  40. break;
  41. }
  42. } while ((action = actions[0]) && action.id === flushId && actions.shift());
  43. this._active = false;
  44. if (error) {
  45. while ((action = actions[0]) && action.id === flushId && actions.shift()) {
  46. action.unsubscribe();
  47. }
  48. throw error;
  49. }
  50. };
  51. return AnimationFrameScheduler;
  52. }(AsyncScheduler_1.AsyncScheduler));
  53. exports.AnimationFrameScheduler = AnimationFrameScheduler;
  54. //# sourceMappingURL=AnimationFrameScheduler.js.map