@netless/app-presentation 0.1.9-beta.3 → 0.1.9-beta.5
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 +3 -1
- package/dist/index.global.js +32 -16
- package/dist/index.js +32 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app-presentation.ts +8 -1
- package/src/scrollbar/index.ts +30 -15
package/dist/index.d.ts
CHANGED
|
@@ -311,7 +311,7 @@ interface ScrollbarEventCallback {
|
|
|
311
311
|
onScrollbarDragEnd?: () => void;
|
|
312
312
|
onScrollbarDragX?: (x: number) => void;
|
|
313
313
|
onScrollbarDragY?: (y: number) => void;
|
|
314
|
-
onScrollCameraUpdated?: (originScale: number, scale: number) => void;
|
|
314
|
+
onScrollCameraUpdated?: (appid: string, originScale: number, scale: number) => void;
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
type Logger = (...data: any[]) => void;
|
|
@@ -380,6 +380,8 @@ interface PresentationController {
|
|
|
380
380
|
}) => void;
|
|
381
381
|
/** get the origin scale */
|
|
382
382
|
getOriginScale: () => number;
|
|
383
|
+
/** get the view scale */
|
|
384
|
+
getScale: () => number;
|
|
383
385
|
}
|
|
384
386
|
|
|
385
387
|
declare const NetlessAppPresentation: NetlessApp<{}, {}, PresentationAppOptions, PresentationController>;
|
package/dist/index.global.js
CHANGED
|
@@ -6821,6 +6821,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
6821
6821
|
this.namespace = "netless-app-presentation";
|
|
6822
6822
|
this.scrollContainer = document.createElement("div");
|
|
6823
6823
|
this.option = {
|
|
6824
|
+
appId: "",
|
|
6824
6825
|
getPageSize: () => {
|
|
6825
6826
|
return {
|
|
6826
6827
|
width: 0,
|
|
@@ -6850,7 +6851,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
6850
6851
|
this.scrollbarY.style.display = ratio === 1 ? "none" : "block";
|
|
6851
6852
|
this.scrollbarY.style.transform = `translateY(${scrollY}px)`;
|
|
6852
6853
|
}
|
|
6853
|
-
(_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollCameraUpdated) == null ? void 0 : _b.call(_a, originScale, scale);
|
|
6854
|
+
(_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollCameraUpdated) == null ? void 0 : _b.call(_a, this.appId, originScale, scale);
|
|
6854
6855
|
}, 50);
|
|
6855
6856
|
this.onDragStart = () => {
|
|
6856
6857
|
var _a, _b;
|
|
@@ -6911,6 +6912,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
6911
6912
|
this.scrollContainer.className = this.c("scrollbar-container");
|
|
6912
6913
|
this.container = container;
|
|
6913
6914
|
this.option = option;
|
|
6915
|
+
this.appId = option.appId;
|
|
6914
6916
|
this.readonly = option.readonly || false;
|
|
6915
6917
|
this.view = view;
|
|
6916
6918
|
this.init();
|
|
@@ -6920,9 +6922,8 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
6920
6922
|
}
|
|
6921
6923
|
setReadonly(bol) {
|
|
6922
6924
|
this.readonly = bol;
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
} else {
|
|
6925
|
+
this.destroy();
|
|
6926
|
+
if (!this.readonly) {
|
|
6926
6927
|
this.init();
|
|
6927
6928
|
}
|
|
6928
6929
|
}
|
|
@@ -6987,16 +6988,27 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
6987
6988
|
this.onCameraUpdated();
|
|
6988
6989
|
}
|
|
6989
6990
|
destroy() {
|
|
6990
|
-
var _a, _b, _c, _d;
|
|
6991
6991
|
this.view.callbacks.off("onCameraUpdated", this.onCameraUpdated);
|
|
6992
|
-
(
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
this.
|
|
6999
|
-
|
|
6992
|
+
if (this.scrollbarX && this.scrollbarContainerX) {
|
|
6993
|
+
this.scrollbarContainerX.removeChild(this.scrollbarX);
|
|
6994
|
+
this.scrollbarX.remove();
|
|
6995
|
+
this.scrollbarContainerX.remove();
|
|
6996
|
+
this.scrollbarX = void 0;
|
|
6997
|
+
}
|
|
6998
|
+
if (this.scrollbarY && this.scrollbarContainerY) {
|
|
6999
|
+
this.scrollbarContainerY.removeChild(this.scrollbarY);
|
|
7000
|
+
this.scrollbarY.remove();
|
|
7001
|
+
this.scrollbarContainerY.remove();
|
|
7002
|
+
this.scrollbarY = void 0;
|
|
7003
|
+
}
|
|
7004
|
+
if (this.draggableX) {
|
|
7005
|
+
this.draggableX.destroy();
|
|
7006
|
+
this.draggableX = void 0;
|
|
7007
|
+
}
|
|
7008
|
+
if (this.draggableY) {
|
|
7009
|
+
this.draggableY.destroy();
|
|
7010
|
+
this.draggableY = void 0;
|
|
7011
|
+
}
|
|
7000
7012
|
}
|
|
7001
7013
|
};
|
|
7002
7014
|
|
|
@@ -7233,7 +7245,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7233
7245
|
dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
|
|
7234
7246
|
const box = context.getBox();
|
|
7235
7247
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
|
|
7236
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
7248
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.5";
|
|
7237
7249
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
7238
7250
|
app.log = log;
|
|
7239
7251
|
if (options.justDocsViewReadonly) {
|
|
@@ -7277,6 +7289,9 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7277
7289
|
const { width, height } = getPageSize();
|
|
7278
7290
|
return Math.min(size.height / height, size.width / width);
|
|
7279
7291
|
};
|
|
7292
|
+
const getScale = () => {
|
|
7293
|
+
return view.camera.scale;
|
|
7294
|
+
};
|
|
7280
7295
|
const moveCamera = (camera) => {
|
|
7281
7296
|
if (context.getIsWritable()) {
|
|
7282
7297
|
view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
|
|
@@ -7289,6 +7304,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7289
7304
|
if (options.useScrollbar) {
|
|
7290
7305
|
dispose2.make(() => {
|
|
7291
7306
|
scrollbar = new Scrollbar(app.contentDOM, {
|
|
7307
|
+
appId: context.appId,
|
|
7292
7308
|
getPageSize,
|
|
7293
7309
|
getOriginScale,
|
|
7294
7310
|
syncView,
|
|
@@ -7421,7 +7437,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7421
7437
|
scrollbar.setReadonly(bol);
|
|
7422
7438
|
}
|
|
7423
7439
|
};
|
|
7424
|
-
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale };
|
|
7440
|
+
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale };
|
|
7425
7441
|
dispose2.add(listen(window, "message", (ev) => {
|
|
7426
7442
|
if (ev.data === "@netless/_presentation_") {
|
|
7427
7443
|
if (typeof window !== "undefined")
|
|
@@ -7477,7 +7493,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7477
7493
|
};
|
|
7478
7494
|
|
|
7479
7495
|
// src/index.ts
|
|
7480
|
-
var version = "0.1.9-beta.
|
|
7496
|
+
var version = "0.1.9-beta.5";
|
|
7481
7497
|
/*! Bundled license information:
|
|
7482
7498
|
|
|
7483
7499
|
lodash/lodash.js:
|
package/dist/index.js
CHANGED
|
@@ -6822,6 +6822,7 @@ var Scrollbar = class {
|
|
|
6822
6822
|
this.namespace = "netless-app-presentation";
|
|
6823
6823
|
this.scrollContainer = document.createElement("div");
|
|
6824
6824
|
this.option = {
|
|
6825
|
+
appId: "",
|
|
6825
6826
|
getPageSize: () => {
|
|
6826
6827
|
return {
|
|
6827
6828
|
width: 0,
|
|
@@ -6851,7 +6852,7 @@ var Scrollbar = class {
|
|
|
6851
6852
|
this.scrollbarY.style.display = ratio === 1 ? "none" : "block";
|
|
6852
6853
|
this.scrollbarY.style.transform = `translateY(${scrollY}px)`;
|
|
6853
6854
|
}
|
|
6854
|
-
(_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollCameraUpdated) == null ? void 0 : _b.call(_a, originScale, scale);
|
|
6855
|
+
(_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollCameraUpdated) == null ? void 0 : _b.call(_a, this.appId, originScale, scale);
|
|
6855
6856
|
}, 50);
|
|
6856
6857
|
this.onDragStart = () => {
|
|
6857
6858
|
var _a, _b;
|
|
@@ -6912,6 +6913,7 @@ var Scrollbar = class {
|
|
|
6912
6913
|
this.scrollContainer.className = this.c("scrollbar-container");
|
|
6913
6914
|
this.container = container;
|
|
6914
6915
|
this.option = option;
|
|
6916
|
+
this.appId = option.appId;
|
|
6915
6917
|
this.readonly = option.readonly || false;
|
|
6916
6918
|
this.view = view;
|
|
6917
6919
|
this.init();
|
|
@@ -6921,9 +6923,8 @@ var Scrollbar = class {
|
|
|
6921
6923
|
}
|
|
6922
6924
|
setReadonly(bol) {
|
|
6923
6925
|
this.readonly = bol;
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
} else {
|
|
6926
|
+
this.destroy();
|
|
6927
|
+
if (!this.readonly) {
|
|
6927
6928
|
this.init();
|
|
6928
6929
|
}
|
|
6929
6930
|
}
|
|
@@ -6988,16 +6989,27 @@ var Scrollbar = class {
|
|
|
6988
6989
|
this.onCameraUpdated();
|
|
6989
6990
|
}
|
|
6990
6991
|
destroy() {
|
|
6991
|
-
var _a, _b, _c, _d;
|
|
6992
6992
|
this.view.callbacks.off("onCameraUpdated", this.onCameraUpdated);
|
|
6993
|
-
(
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
this.
|
|
7000
|
-
|
|
6993
|
+
if (this.scrollbarX && this.scrollbarContainerX) {
|
|
6994
|
+
this.scrollbarContainerX.removeChild(this.scrollbarX);
|
|
6995
|
+
this.scrollbarX.remove();
|
|
6996
|
+
this.scrollbarContainerX.remove();
|
|
6997
|
+
this.scrollbarX = void 0;
|
|
6998
|
+
}
|
|
6999
|
+
if (this.scrollbarY && this.scrollbarContainerY) {
|
|
7000
|
+
this.scrollbarContainerY.removeChild(this.scrollbarY);
|
|
7001
|
+
this.scrollbarY.remove();
|
|
7002
|
+
this.scrollbarContainerY.remove();
|
|
7003
|
+
this.scrollbarY = void 0;
|
|
7004
|
+
}
|
|
7005
|
+
if (this.draggableX) {
|
|
7006
|
+
this.draggableX.destroy();
|
|
7007
|
+
this.draggableX = void 0;
|
|
7008
|
+
}
|
|
7009
|
+
if (this.draggableY) {
|
|
7010
|
+
this.draggableY.destroy();
|
|
7011
|
+
this.draggableY = void 0;
|
|
7012
|
+
}
|
|
7001
7013
|
}
|
|
7002
7014
|
};
|
|
7003
7015
|
|
|
@@ -7234,7 +7246,7 @@ var NetlessAppPresentation = {
|
|
|
7234
7246
|
dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
|
|
7235
7247
|
const box = context.getBox();
|
|
7236
7248
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
|
|
7237
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
7249
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.5";
|
|
7238
7250
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
7239
7251
|
app.log = log;
|
|
7240
7252
|
if (options.justDocsViewReadonly) {
|
|
@@ -7278,6 +7290,9 @@ var NetlessAppPresentation = {
|
|
|
7278
7290
|
const { width, height } = getPageSize();
|
|
7279
7291
|
return Math.min(size.height / height, size.width / width);
|
|
7280
7292
|
};
|
|
7293
|
+
const getScale = () => {
|
|
7294
|
+
return view.camera.scale;
|
|
7295
|
+
};
|
|
7281
7296
|
const moveCamera = (camera) => {
|
|
7282
7297
|
if (context.getIsWritable()) {
|
|
7283
7298
|
view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
|
|
@@ -7290,6 +7305,7 @@ var NetlessAppPresentation = {
|
|
|
7290
7305
|
if (options.useScrollbar) {
|
|
7291
7306
|
dispose2.make(() => {
|
|
7292
7307
|
scrollbar = new Scrollbar(app.contentDOM, {
|
|
7308
|
+
appId: context.appId,
|
|
7293
7309
|
getPageSize,
|
|
7294
7310
|
getOriginScale,
|
|
7295
7311
|
syncView,
|
|
@@ -7422,7 +7438,7 @@ var NetlessAppPresentation = {
|
|
|
7422
7438
|
scrollbar.setReadonly(bol);
|
|
7423
7439
|
}
|
|
7424
7440
|
};
|
|
7425
|
-
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale };
|
|
7441
|
+
const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale };
|
|
7426
7442
|
dispose2.add(listen(window, "message", (ev) => {
|
|
7427
7443
|
if (ev.data === "@netless/_presentation_") {
|
|
7428
7444
|
if (typeof window !== "undefined")
|
|
@@ -7478,7 +7494,7 @@ var install = (register, options = {}) => {
|
|
|
7478
7494
|
};
|
|
7479
7495
|
|
|
7480
7496
|
// src/index.ts
|
|
7481
|
-
var version = "0.1.9-beta.
|
|
7497
|
+
var version = "0.1.9-beta.5";
|
|
7482
7498
|
/*! Bundled license information:
|
|
7483
7499
|
|
|
7484
7500
|
lodash/lodash.js:
|