@netless/app-slide 0.2.13 → 0.2.15
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/main.cjs.js +9 -9
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +18 -13
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +9 -9
- package/dist/main.iife.js.map +1 -1
- package/dist/utils/freezer.d.ts +3 -2
- package/package.json +1 -1
- package/src/DocsViewer/index.ts +5 -7
- package/src/index.ts +1 -1
- package/src/utils/freezer.ts +11 -2
package/dist/utils/freezer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RegisterParams } from "@netless/window-manager";
|
|
1
|
+
import type { ReadonlyTeleBox, RegisterParams } from "@netless/window-manager";
|
|
2
2
|
export interface FreezableSlide {
|
|
3
3
|
freeze: () => void;
|
|
4
4
|
unfreeze: () => void;
|
|
@@ -7,9 +7,10 @@ export declare let useFreezer: boolean;
|
|
|
7
7
|
export declare const FreezerLength = 2;
|
|
8
8
|
export declare const apps: {
|
|
9
9
|
map: Map<string, FreezableSlide>;
|
|
10
|
+
boxes: Map<string, ReadonlyTeleBox>;
|
|
10
11
|
queue: string[];
|
|
11
12
|
validateQueue(): void;
|
|
12
|
-
set(appId: string, slide: FreezableSlide): void;
|
|
13
|
+
set(appId: string, slide: FreezableSlide, box: ReadonlyTeleBox): void;
|
|
13
14
|
delete(appId: string): void;
|
|
14
15
|
focus(appId: string): void;
|
|
15
16
|
};
|
package/package.json
CHANGED
package/src/DocsViewer/index.ts
CHANGED
|
@@ -71,6 +71,7 @@ export class DocsViewer {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
public destroy(): void {
|
|
74
|
+
this.previewLazyLoad?.destroy();
|
|
74
75
|
this.sideEffect.flushAll();
|
|
75
76
|
this.unmount();
|
|
76
77
|
}
|
|
@@ -126,13 +127,6 @@ export class DocsViewer {
|
|
|
126
127
|
const $preview = document.createElement("div");
|
|
127
128
|
$preview.className = this.wrapClassName("preview") + " tele-fancy-scrollbar";
|
|
128
129
|
this.$preview = $preview;
|
|
129
|
-
this.sideEffect.add(() => {
|
|
130
|
-
this.previewLazyLoad = new LazyLoad({
|
|
131
|
-
container: this.$preview,
|
|
132
|
-
elements_selector: `.${this.wrapClassName("preview-page>img")}`,
|
|
133
|
-
});
|
|
134
|
-
return () => this.previewLazyLoad?.destroy();
|
|
135
|
-
});
|
|
136
130
|
|
|
137
131
|
this.refreshPreview();
|
|
138
132
|
|
|
@@ -347,6 +341,10 @@ export class DocsViewer {
|
|
|
347
341
|
"." + this.wrapClassName(`preview-page-${this.pageIndex}`)
|
|
348
342
|
);
|
|
349
343
|
if ($previewPage) {
|
|
344
|
+
this.previewLazyLoad ||= new LazyLoad({
|
|
345
|
+
container: this.$preview,
|
|
346
|
+
elements_selector: `.${this.wrapClassName("preview-page>img")}`,
|
|
347
|
+
});
|
|
350
348
|
this.$preview.scrollTo({
|
|
351
349
|
top: $previewPage.offsetTop - 16,
|
|
352
350
|
});
|
package/src/index.ts
CHANGED
|
@@ -126,7 +126,7 @@ const SlideApp: NetlessApp<Attributes, MagixEvents, AppOptions, Controller> = {
|
|
|
126
126
|
...options,
|
|
127
127
|
onPageChanged,
|
|
128
128
|
});
|
|
129
|
-
if (useFreezer) apps.set(context.appId, slideController);
|
|
129
|
+
if (useFreezer) apps.set(context.appId, slideController, box);
|
|
130
130
|
logger.setAppController(context.appId, slideController);
|
|
131
131
|
if (import.meta.env.DEV) {
|
|
132
132
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/src/utils/freezer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RegisterParams } from "@netless/window-manager";
|
|
1
|
+
import type { ReadonlyTeleBox, RegisterParams } from "@netless/window-manager";
|
|
2
2
|
import { log } from "./logger";
|
|
3
3
|
|
|
4
4
|
export interface FreezableSlide {
|
|
@@ -15,8 +15,15 @@ const inspect = (arr: string[]) => {
|
|
|
15
15
|
|
|
16
16
|
export const apps = {
|
|
17
17
|
map: new Map<string, FreezableSlide>(),
|
|
18
|
+
boxes: new Map<string, ReadonlyTeleBox>(),
|
|
18
19
|
queue: [] as string[],
|
|
19
20
|
validateQueue() {
|
|
21
|
+
// queue = [5, 4, 3, 2, 1]
|
|
22
|
+
this.queue.sort((a, b) => {
|
|
23
|
+
const za = this.boxes.get(a)?.zIndex ?? 0;
|
|
24
|
+
const zb = this.boxes.get(b)?.zIndex ?? 0;
|
|
25
|
+
return -(za - zb);
|
|
26
|
+
});
|
|
20
27
|
log("[Slide] freezer: validate", inspect(this.queue));
|
|
21
28
|
while (this.queue.length > FreezerLength) {
|
|
22
29
|
const appId = this.queue.pop() as string;
|
|
@@ -27,9 +34,10 @@ export const apps = {
|
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
},
|
|
30
|
-
set(appId: string, slide: FreezableSlide) {
|
|
37
|
+
set(appId: string, slide: FreezableSlide, box: ReadonlyTeleBox) {
|
|
31
38
|
log("[Slide] freezer: add", appId, inspect(this.queue));
|
|
32
39
|
this.map.set(appId, slide);
|
|
40
|
+
this.boxes.set(appId, box);
|
|
33
41
|
if (!this.queue.includes(appId)) {
|
|
34
42
|
this.queue.unshift(appId);
|
|
35
43
|
}
|
|
@@ -37,6 +45,7 @@ export const apps = {
|
|
|
37
45
|
},
|
|
38
46
|
delete(appId: string) {
|
|
39
47
|
this.map.delete(appId);
|
|
48
|
+
this.boxes.delete(appId);
|
|
40
49
|
this.queue = this.queue.filter(id => id !== appId);
|
|
41
50
|
log("[Slide] freezer: delete", appId, inspect(this.queue));
|
|
42
51
|
},
|