1 | /** PURE_IMPORTS_START tslib,_AsyncAction PURE_IMPORTS_END */
|
---|
2 | import * as tslib_1 from "tslib";
|
---|
3 | import { AsyncAction } from './AsyncAction';
|
---|
4 | var AnimationFrameAction = /*@__PURE__*/ (function (_super) {
|
---|
5 | tslib_1.__extends(AnimationFrameAction, _super);
|
---|
6 | function AnimationFrameAction(scheduler, work) {
|
---|
7 | var _this = _super.call(this, scheduler, work) || this;
|
---|
8 | _this.scheduler = scheduler;
|
---|
9 | _this.work = work;
|
---|
10 | return _this;
|
---|
11 | }
|
---|
12 | AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
|
---|
13 | if (delay === void 0) {
|
---|
14 | delay = 0;
|
---|
15 | }
|
---|
16 | if (delay !== null && delay > 0) {
|
---|
17 | return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
|
---|
18 | }
|
---|
19 | scheduler.actions.push(this);
|
---|
20 | return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
|
---|
21 | };
|
---|
22 | AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
|
---|
23 | if (delay === void 0) {
|
---|
24 | delay = 0;
|
---|
25 | }
|
---|
26 | if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
|
---|
27 | return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
|
---|
28 | }
|
---|
29 | if (scheduler.actions.length === 0) {
|
---|
30 | cancelAnimationFrame(id);
|
---|
31 | scheduler.scheduled = undefined;
|
---|
32 | }
|
---|
33 | return undefined;
|
---|
34 | };
|
---|
35 | return AnimationFrameAction;
|
---|
36 | }(AsyncAction));
|
---|
37 | export { AnimationFrameAction };
|
---|
38 | //# sourceMappingURL=AnimationFrameAction.js.map
|
---|