| 1 |
"use strict"; |
| 2 |
var __extends = (this && this.__extends) || (function () { |
| 3 |
var extendStatics = function (d, b) { |
| 4 |
extendStatics = Object.setPrototypeOf || |
| 5 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 6 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 7 |
return extendStatics(d, b); |
| 8 |
}; |
| 9 |
return function (d, b) { |
| 10 |
if (typeof b !== "function" && b !== null) |
| 11 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 12 |
extendStatics(d, b); |
| 13 |
function __() { this.constructor = d; } |
| 14 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 15 |
}; |
| 16 |
})(); |
| 17 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 18 |
exports.AnimationFrameAction = void 0; |
| 19 |
var AsyncAction_1 = require("./AsyncAction"); |
| 20 |
var animationFrameProvider_1 = require("./animationFrameProvider"); |
| 21 |
var AnimationFrameAction = (function (_super) { |
| 22 |
__extends(AnimationFrameAction, _super); |
| 23 |
function AnimationFrameAction(scheduler, work) { |
| 24 |
var _this = _super.call(this, scheduler, work) || this; |
| 25 |
_this.scheduler = scheduler; |
| 26 |
_this.work = work; |
| 27 |
return _this; |
| 28 |
} |
| 29 |
AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) { |
| 30 |
if (delay === void 0) { delay = 0; } |
| 31 |
if (delay !== null && delay > 0) { |
| 32 |
return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); |
| 33 |
} |
| 34 |
scheduler.actions.push(this); |
| 35 |
return scheduler._scheduled || (scheduler._scheduled = animationFrameProvider_1.animationFrameProvider.requestAnimationFrame(function () { return scheduler.flush(undefined); })); |
| 36 |
}; |
| 37 |
AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) { |
| 38 |
var _a; |
| 39 |
if (delay === void 0) { delay = 0; } |
| 40 |
if (delay != null ? delay > 0 : this.delay > 0) { |
| 41 |
return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); |
| 42 |
} |
| 43 |
var actions = scheduler.actions; |
| 44 |
if (id != null && id === scheduler._scheduled && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) { |
| 45 |
animationFrameProvider_1.animationFrameProvider.cancelAnimationFrame(id); |
| 46 |
scheduler._scheduled = undefined; |
| 47 |
} |
| 48 |
return undefined; |
| 49 |
}; |
| 50 |
return AnimationFrameAction; |
| 51 |
}(AsyncAction_1.AsyncAction)); |
| 52 |
exports.AnimationFrameAction = AnimationFrameAction; |
| 53 |
//# sourceMappingURL=AnimationFrameAction.js.map |