@netless/slide 0.5.13 → 0.5.16-y.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/FrozenTaskManager.d.ts +1 -1
- package/lib/FrozenTaskManager.js +17 -6
- package/lib/Slide.js +2 -2
- package/lib/SyncTaskManager.d.ts +1 -0
- package/lib/SyncTaskManager.js +12 -7
- package/lib/Ticker.d.ts +2 -0
- package/lib/Ticker.js +2 -0
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@ export interface FrozenTask {
|
|
|
6
6
|
export declare class FrozenTaskManager {
|
|
7
7
|
private tasks;
|
|
8
8
|
private isDestroy;
|
|
9
|
-
|
|
9
|
+
private isScheduling;
|
|
10
10
|
private schedule;
|
|
11
11
|
private getRunningTask;
|
|
12
12
|
addTask(type: "frozen" | "release", fn: () => Promise<void>): void;
|
package/lib/FrozenTaskManager.js
CHANGED
|
@@ -3,21 +3,29 @@ var FrozenTaskManager = /** @class */ (function () {
|
|
|
3
3
|
var _this = this;
|
|
4
4
|
this.tasks = [];
|
|
5
5
|
this.isDestroy = false;
|
|
6
|
+
this.isScheduling = false;
|
|
6
7
|
this.schedule = function () {
|
|
8
|
+
_this.isScheduling = true;
|
|
7
9
|
var task = _this.tasks.shift();
|
|
8
10
|
if (task && !_this.isDestroy) {
|
|
9
11
|
task.status = "running";
|
|
10
12
|
task.fn.apply(null).then(function () {
|
|
11
|
-
|
|
13
|
+
if (_this.tasks.length > 0) {
|
|
14
|
+
window.requestAnimationFrame(_this.schedule);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
_this.isScheduling = false;
|
|
18
|
+
}
|
|
12
19
|
}).catch(function () {
|
|
13
|
-
|
|
20
|
+
if (_this.tasks.length > 0) {
|
|
21
|
+
window.requestAnimationFrame(_this.schedule);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
_this.isScheduling = false;
|
|
25
|
+
}
|
|
14
26
|
});
|
|
15
27
|
}
|
|
16
|
-
else {
|
|
17
|
-
window.setTimeout(_this.schedule);
|
|
18
|
-
}
|
|
19
28
|
};
|
|
20
|
-
this.schedule();
|
|
21
29
|
}
|
|
22
30
|
FrozenTaskManager.prototype.getRunningTask = function () {
|
|
23
31
|
if (this.tasks[0] && this.tasks[0].status === "running") {
|
|
@@ -38,6 +46,9 @@ var FrozenTaskManager = /** @class */ (function () {
|
|
|
38
46
|
else {
|
|
39
47
|
this.tasks = this.tasks.filter(function (v) { return v.type !== type; });
|
|
40
48
|
this.tasks.push(task);
|
|
49
|
+
if (!this.isScheduling) {
|
|
50
|
+
this.schedule();
|
|
51
|
+
}
|
|
41
52
|
}
|
|
42
53
|
};
|
|
43
54
|
FrozenTaskManager.prototype.destroy = function () {
|