a zip code crypto-currency system good for red ONLY

AnimationFrameAction.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /** PURE_IMPORTS_START ._AsyncAction,.._util_AnimationFrame PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { AsyncAction } from './AsyncAction';
  10. import { AnimationFrame } from '../util/AnimationFrame';
  11. /**
  12. * We need this JSDoc comment for affecting ESDoc.
  13. * @ignore
  14. * @extends {Ignored}
  15. */
  16. export var AnimationFrameAction = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  17. __extends(AnimationFrameAction, _super);
  18. function AnimationFrameAction(scheduler, work) {
  19. _super.call(this, scheduler, work);
  20. this.scheduler = scheduler;
  21. this.work = work;
  22. }
  23. AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  24. if (delay === void 0) {
  25. delay = 0;
  26. }
  27. // If delay is greater than 0, request as an async action.
  28. if (delay !== null && delay > 0) {
  29. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  30. }
  31. // Push the action to the end of the scheduler queue.
  32. scheduler.actions.push(this);
  33. // If an animation frame has already been requested, don't request another
  34. // one. If an animation frame hasn't been requested yet, request one. Return
  35. // the current animation frame request id.
  36. return scheduler.scheduled || (scheduler.scheduled = AnimationFrame.requestAnimationFrame(scheduler.flush.bind(scheduler, null)));
  37. };
  38. AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  39. if (delay === void 0) {
  40. delay = 0;
  41. }
  42. // If delay exists and is greater than 0, or if the delay is null (the
  43. // action wasn't rescheduled) but was originally scheduled as an async
  44. // action, then recycle as an async action.
  45. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  46. return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
  47. }
  48. // If the scheduler queue is empty, cancel the requested animation frame and
  49. // set the scheduled flag to undefined so the next AnimationFrameAction will
  50. // request its own.
  51. if (scheduler.actions.length === 0) {
  52. AnimationFrame.cancelAnimationFrame(id);
  53. scheduler.scheduled = undefined;
  54. }
  55. // Return undefined so the action knows to request a new async id if it's rescheduled.
  56. return undefined;
  57. };
  58. return AnimationFrameAction;
  59. }(AsyncAction));
  60. //# sourceMappingURL=AnimationFrameAction.js.map