@netless/app-presentation 0.1.12 → 0.1.13-beta.1
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/dist/index.d.ts +18 -2
- package/dist/index.global.js +445 -99
- package/dist/index.js +445 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +445 -99
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app-presentation.ts +1041 -499
- package/src/preload.ts +14 -0
package/src/preload.ts
CHANGED
|
@@ -35,6 +35,9 @@ export class Preload implements IDisposable {
|
|
|
35
35
|
// 当前触摸的索引
|
|
36
36
|
touchIndex: number = 0;
|
|
37
37
|
preloadSize: number = 0;
|
|
38
|
+
// 暂停后不再创建预加载链接(app 失焦降级时调用);已插入的 link 会被移除,
|
|
39
|
+
// 挂起的 idle 回调重新进入 touch() 时也会被跳过
|
|
40
|
+
paused: boolean = false;
|
|
38
41
|
constructor(readonly pages: PresentationPage[]) {
|
|
39
42
|
this.preloadMap = new Map(pages.map((e,index) => [index, {
|
|
40
43
|
src: e.src,
|
|
@@ -43,7 +46,18 @@ export class Preload implements IDisposable {
|
|
|
43
46
|
this.preloadSize = this.preloadMap.size;
|
|
44
47
|
this.touch(0, true);
|
|
45
48
|
}
|
|
49
|
+
pause() {
|
|
50
|
+
if (this.paused) return;
|
|
51
|
+
this.paused = true;
|
|
52
|
+
this.destroySomeLink();
|
|
53
|
+
}
|
|
54
|
+
resume(index?: number) {
|
|
55
|
+
if (!this.paused) return;
|
|
56
|
+
this.paused = false;
|
|
57
|
+
this.touch(index ?? this.touchIndex, true);
|
|
58
|
+
}
|
|
46
59
|
touch(index: number, force: boolean = false) {
|
|
60
|
+
if (this.paused) return;
|
|
47
61
|
if (index >= this.preloadSize) {
|
|
48
62
|
this.touchIndex = 0;
|
|
49
63
|
} else {
|