Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
981 bytes
|
Line | |
---|
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 |
---|
Note:
See
TracBrowser
for help on using the repository browser.