Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AnimationFrameAction.js 981B

1234567891011121314151617181920212223242526
  1. import { AsyncAction } from './AsyncAction';
  2. export class AnimationFrameAction extends AsyncAction {
  3. constructor(scheduler, work) {
  4. super(scheduler, work);
  5. this.scheduler = scheduler;
  6. this.work = work;
  7. }
  8. requestAsyncId(scheduler, id, delay = 0) {
  9. if (delay !== null && delay > 0) {
  10. return super.requestAsyncId(scheduler, id, delay);
  11. }
  12. scheduler.actions.push(this);
  13. return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(() => scheduler.flush(null)));
  14. }
  15. recycleAsyncId(scheduler, id, delay = 0) {
  16. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  17. return super.recycleAsyncId(scheduler, id, delay);
  18. }
  19. if (scheduler.actions.length === 0) {
  20. cancelAnimationFrame(id);
  21. scheduler.scheduled = undefined;
  22. }
  23. return undefined;
  24. }
  25. }
  26. //# sourceMappingURL=AnimationFrameAction.js.map