@netless/app-slide 0.2.93 → 0.2.94
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/README-zh.md +3 -3
- package/README.md +3 -3
- package/dist/index.d.ts +11 -3
- package/dist/main.cjs.js +56 -56
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +116 -17
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +55 -55
- package/dist/main.iife.js.map +1 -1
- package/package.json +8 -8
- package/src/DocsViewer/ResizableContainer.ts +52 -32
- package/src/DocsViewer/ScrollBar.ts +57 -51
- package/src/SlideController/index.ts +88 -5
- package/src/SlideDocsViewer/index.ts +24 -11
- package/src/index.ts +12 -5
- package/LICENSE +0 -21
package/dist/main.es.js
CHANGED
|
@@ -38053,19 +38053,81 @@ class SlideControllerBase {
|
|
|
38053
38053
|
this._toFreeze = -1;
|
|
38054
38054
|
}
|
|
38055
38055
|
};
|
|
38056
|
+
this.bindAppStateChangeEvent = () => {
|
|
38057
|
+
try {
|
|
38058
|
+
const boxStatus = this.context.getBoxStatus();
|
|
38059
|
+
if (boxStatus) {
|
|
38060
|
+
const appProxy = this.context.getAppProxy();
|
|
38061
|
+
if (appProxy) {
|
|
38062
|
+
this.context.emitter.on("boxStatusChange", this.onAppStatusChangeHandler);
|
|
38063
|
+
}
|
|
38064
|
+
} else {
|
|
38065
|
+
const windowManager = this.context.getWindowManager();
|
|
38066
|
+
if (windowManager) {
|
|
38067
|
+
windowManager.emitter.on("boxStateChange", this.onAppStateChangeHandler);
|
|
38068
|
+
}
|
|
38069
|
+
}
|
|
38070
|
+
} catch (error) {
|
|
38071
|
+
log(
|
|
38072
|
+
"[Slide] bind app state change event failed, because should update window manager to latest version"
|
|
38073
|
+
);
|
|
38074
|
+
}
|
|
38075
|
+
};
|
|
38076
|
+
this.onAppStateChangeHandler = (state) => {
|
|
38077
|
+
if (state === "minimized") {
|
|
38078
|
+
log("[Slide] freeze because app state is minimized");
|
|
38079
|
+
this.freeze();
|
|
38080
|
+
}
|
|
38081
|
+
};
|
|
38082
|
+
this.onAppStatusChangeHandler = (payload) => {
|
|
38083
|
+
const { appId, status } = payload;
|
|
38084
|
+
if (appId === this.context.appId && status === "minimized") {
|
|
38085
|
+
log("[Slide] freeze because app status is minimized");
|
|
38086
|
+
this.freeze();
|
|
38087
|
+
}
|
|
38088
|
+
};
|
|
38089
|
+
this.getAppStatus = () => {
|
|
38090
|
+
try {
|
|
38091
|
+
const boxStatus = this.context.getBoxStatus();
|
|
38092
|
+
if (boxStatus) {
|
|
38093
|
+
return boxStatus;
|
|
38094
|
+
}
|
|
38095
|
+
const windowManager = this.context.getWindowManager();
|
|
38096
|
+
const boxstate = windowManager.boxState;
|
|
38097
|
+
return boxstate;
|
|
38098
|
+
} catch (error) {
|
|
38099
|
+
return void 0;
|
|
38100
|
+
}
|
|
38101
|
+
};
|
|
38056
38102
|
this.onVisibilityChange = async () => {
|
|
38103
|
+
const appStatus = this.getAppStatus();
|
|
38104
|
+
if (appStatus === "minimized") {
|
|
38105
|
+
log("[Slide] do nothing because app state is minimized");
|
|
38106
|
+
return;
|
|
38107
|
+
}
|
|
38057
38108
|
if (!(this.visible = document.visibilityState === "visible")) {
|
|
38058
38109
|
this.savedIsFrozen = this.isFrozen;
|
|
38059
38110
|
log("[Slide] freeze because tab becomes invisible");
|
|
38060
38111
|
this.freeze();
|
|
38061
38112
|
} else {
|
|
38062
|
-
log("[Slide] unfreeze because tab becomes visible", { savedIsFrozen: this.savedIsFrozen });
|
|
38063
38113
|
if (!this.savedIsFrozen) {
|
|
38114
|
+
log("[Slide] unfreeze because tab becomes visible", { savedIsFrozen: this.savedIsFrozen });
|
|
38064
38115
|
this.unfreeze();
|
|
38065
38116
|
}
|
|
38066
38117
|
}
|
|
38067
38118
|
};
|
|
38068
|
-
const {
|
|
38119
|
+
const {
|
|
38120
|
+
context,
|
|
38121
|
+
onRenderStart,
|
|
38122
|
+
onPageChanged,
|
|
38123
|
+
onTransitionStart,
|
|
38124
|
+
onTransitionEnd,
|
|
38125
|
+
onNavigate,
|
|
38126
|
+
onError,
|
|
38127
|
+
onRenderError,
|
|
38128
|
+
showRenderError,
|
|
38129
|
+
invisibleBehavior
|
|
38130
|
+
} = props;
|
|
38069
38131
|
this.invisibleBehavior = invisibleBehavior != null ? invisibleBehavior : "frozen";
|
|
38070
38132
|
this.onRenderStart = onRenderStart;
|
|
38071
38133
|
this.onPageChanged = onPageChanged;
|
|
@@ -38142,7 +38204,18 @@ class SlideControllerBase {
|
|
|
38142
38204
|
slide.on(Slide.SLIDE_EVENTS.renderEnd, this.resolveReady);
|
|
38143
38205
|
this.sideEffect.add(() => {
|
|
38144
38206
|
document.addEventListener("visibilitychange", this.onVisibilityChange);
|
|
38145
|
-
|
|
38207
|
+
this.bindAppStateChangeEvent();
|
|
38208
|
+
return () => {
|
|
38209
|
+
document.removeEventListener("visibilitychange", this.onVisibilityChange);
|
|
38210
|
+
try {
|
|
38211
|
+
this.context.emitter.off("boxStatusChange", this.onAppStatusChangeHandler);
|
|
38212
|
+
this.context.getWindowManager().emitter.off("boxStateChange", this.onAppStateChangeHandler);
|
|
38213
|
+
} catch (error) {
|
|
38214
|
+
log(
|
|
38215
|
+
"[Slide] unbind app state change event failed, because should update window manager to latest version"
|
|
38216
|
+
);
|
|
38217
|
+
}
|
|
38218
|
+
};
|
|
38146
38219
|
});
|
|
38147
38220
|
}
|
|
38148
38221
|
syncStateOnce() {
|
|
@@ -39334,7 +39407,10 @@ class ScrollBar {
|
|
|
39334
39407
|
scrollBar.className = "scroll-bar horizontal";
|
|
39335
39408
|
const availableWidth = containerWidth;
|
|
39336
39409
|
const trackWidth = availableWidth;
|
|
39337
|
-
const thumbWidth = Math.max(
|
|
39410
|
+
const thumbWidth = Math.max(
|
|
39411
|
+
30,
|
|
39412
|
+
Math.min(trackWidth, trackWidth * availableWidth / contentWidth)
|
|
39413
|
+
);
|
|
39338
39414
|
scrollBar.style.cssText = `
|
|
39339
39415
|
position: absolute;
|
|
39340
39416
|
bottom: 0;
|
|
@@ -39369,7 +39445,10 @@ class ScrollBar {
|
|
|
39369
39445
|
scrollBar.className = "scroll-bar vertical";
|
|
39370
39446
|
const availableHeight = containerHeight;
|
|
39371
39447
|
const trackHeight = availableHeight;
|
|
39372
|
-
const thumbHeight = Math.max(
|
|
39448
|
+
const thumbHeight = Math.max(
|
|
39449
|
+
30,
|
|
39450
|
+
Math.min(trackHeight, trackHeight * availableHeight / contentHeight)
|
|
39451
|
+
);
|
|
39373
39452
|
scrollBar.style.cssText = `
|
|
39374
39453
|
position: absolute;
|
|
39375
39454
|
top: 0;
|
|
@@ -39433,15 +39512,23 @@ class ScrollBar {
|
|
|
39433
39512
|
scrollRatio = Math.max(0, Math.min(1, scrollRatio));
|
|
39434
39513
|
}
|
|
39435
39514
|
if (orientation === "horizontal") {
|
|
39436
|
-
this.resizableContainer.handleNormalizeTranslate(
|
|
39437
|
-
|
|
39438
|
-
|
|
39439
|
-
|
|
39515
|
+
this.resizableContainer.handleNormalizeTranslate(
|
|
39516
|
+
scrollRatio,
|
|
39517
|
+
(_a = this.resizableContainer["translateY"]) != null ? _a : 0.5,
|
|
39518
|
+
{
|
|
39519
|
+
triggerScrollBar: false,
|
|
39520
|
+
triggerSync: true
|
|
39521
|
+
}
|
|
39522
|
+
);
|
|
39440
39523
|
} else {
|
|
39441
|
-
this.resizableContainer.handleNormalizeTranslate(
|
|
39442
|
-
|
|
39443
|
-
|
|
39444
|
-
|
|
39524
|
+
this.resizableContainer.handleNormalizeTranslate(
|
|
39525
|
+
(_b = this.resizableContainer["translateX"]) != null ? _b : 0.5,
|
|
39526
|
+
scrollRatio,
|
|
39527
|
+
{
|
|
39528
|
+
triggerScrollBar: false,
|
|
39529
|
+
triggerSync: true
|
|
39530
|
+
}
|
|
39531
|
+
);
|
|
39445
39532
|
}
|
|
39446
39533
|
};
|
|
39447
39534
|
const handleEnd = () => {
|
|
@@ -39555,7 +39642,12 @@ class ResizableContainer {
|
|
|
39555
39642
|
}
|
|
39556
39643
|
this.translateX = 0.5;
|
|
39557
39644
|
this.translateY = 0.5;
|
|
39558
|
-
this.renderScrollBar(
|
|
39645
|
+
this.renderScrollBar(
|
|
39646
|
+
parentBounds.width,
|
|
39647
|
+
parentBounds.width * this.scale,
|
|
39648
|
+
parentBounds.height,
|
|
39649
|
+
parentBounds.height * this.scale
|
|
39650
|
+
);
|
|
39559
39651
|
this.handleNormalizeTranslate(this.translateX, this.translateY, {
|
|
39560
39652
|
triggerScrollBar: true,
|
|
39561
39653
|
triggerSync: true
|
|
@@ -39831,7 +39923,10 @@ class SlideDocsViewer {
|
|
|
39831
39923
|
console.log("[SlideDocsViewer] Initial storage state:", this.context.storage.state);
|
|
39832
39924
|
console.log("[SlideDocsViewer] Initial slideScale:", this.context.storage.state.slideScale);
|
|
39833
39925
|
if (this.context.storage.state.slideScale !== void 0) {
|
|
39834
|
-
console.log(
|
|
39926
|
+
console.log(
|
|
39927
|
+
"[SlideDocsViewer] Applying initial slideScale:",
|
|
39928
|
+
this.context.storage.state.slideScale
|
|
39929
|
+
);
|
|
39835
39930
|
applyScale(this.context.storage.state.slideScale);
|
|
39836
39931
|
} else {
|
|
39837
39932
|
console.log("[SlideDocsViewer] No initial slideScale found");
|
|
@@ -39869,7 +39964,11 @@ class SlideDocsViewer {
|
|
|
39869
39964
|
}
|
|
39870
39965
|
render() {
|
|
39871
39966
|
if (!this.resizableContainer) {
|
|
39872
|
-
this.resizableContainer = new ResizableContainer(
|
|
39967
|
+
this.resizableContainer = new ResizableContainer(
|
|
39968
|
+
this.viewer.$content,
|
|
39969
|
+
this.context,
|
|
39970
|
+
this.enableScale
|
|
39971
|
+
);
|
|
39873
39972
|
}
|
|
39874
39973
|
this.renderSlideContainer();
|
|
39875
39974
|
this.renderWhiteboardView();
|
|
@@ -40251,7 +40350,7 @@ class SlidePreviewer {
|
|
|
40251
40350
|
}
|
|
40252
40351
|
}
|
|
40253
40352
|
const usePlugin = /* @__PURE__ */ Slide.Slide.usePlugin.bind(Slide.Slide);
|
|
40254
|
-
const version = "0.2.
|
|
40353
|
+
const version = "0.2.94";
|
|
40255
40354
|
const SlideApp = {
|
|
40256
40355
|
kind: "Slide",
|
|
40257
40356
|
setup(context) {
|