AnimationFrameScheduler.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var AsyncScheduler_1 = require('./AsyncScheduler');
  8. var AnimationFrameScheduler = (function (_super) {
  9. __extends(AnimationFrameScheduler, _super);
  10. function AnimationFrameScheduler() {
  11. _super.apply(this, arguments);
  12. }
  13. AnimationFrameScheduler.prototype.flush = function (action) {
  14. this.active = true;
  15. this.scheduled = undefined;
  16. var actions = this.actions;
  17. var error;
  18. var index = -1;
  19. var count = actions.length;
  20. action = action || actions.shift();
  21. do {
  22. if (error = action.execute(action.state, action.delay)) {
  23. break;
  24. }
  25. } while (++index < count && (action = actions.shift()));
  26. this.active = false;
  27. if (error) {
  28. while (++index < count && (action = actions.shift())) {
  29. action.unsubscribe();
  30. }
  31. throw error;
  32. }
  33. };
  34. return AnimationFrameScheduler;
  35. }(AsyncScheduler_1.AsyncScheduler));
  36. exports.AnimationFrameScheduler = AnimationFrameScheduler;
  37. //# sourceMappingURL=AnimationFrameScheduler.js.map