@netless/app-presentation 0.1.9-beta.3 → 0.1.9-beta.4
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 +10 -4
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app-presentation.ts +8 -1
- package/src/scrollbar/index.ts +7 -3
package/package.json
CHANGED
package/src/app-presentation.ts
CHANGED
|
@@ -72,6 +72,8 @@ export interface PresentationController {
|
|
|
72
72
|
moveCamera: (camera: { centerX: number, centerY: number, scale: number }) => void;
|
|
73
73
|
/** get the origin scale */
|
|
74
74
|
getOriginScale: () => number;
|
|
75
|
+
/** get the view scale */
|
|
76
|
+
getScale: () =>number;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
export { styles }
|
|
@@ -391,6 +393,10 @@ export const NetlessAppPresentation: NetlessApp<{}, {}, PresentationAppOptions,
|
|
|
391
393
|
return Math.min(size.height / height, size.width / width);
|
|
392
394
|
}
|
|
393
395
|
|
|
396
|
+
const getScale =() => {
|
|
397
|
+
return view.camera.scale
|
|
398
|
+
}
|
|
399
|
+
|
|
394
400
|
const moveCamera = (camera: { centerX: number, centerY: number, scale: number }) => {
|
|
395
401
|
if (context.getIsWritable()) {
|
|
396
402
|
view.moveCamera({...camera, animationMode: 'immediately' as AnimationMode});
|
|
@@ -404,6 +410,7 @@ export const NetlessAppPresentation: NetlessApp<{}, {}, PresentationAppOptions,
|
|
|
404
410
|
if (options.useScrollbar) {
|
|
405
411
|
dispose.make(() => {
|
|
406
412
|
scrollbar = new Scrollbar(app.contentDOM, {
|
|
413
|
+
appId: context.appId,
|
|
407
414
|
getPageSize,
|
|
408
415
|
getOriginScale,
|
|
409
416
|
syncView,
|
|
@@ -540,7 +547,7 @@ export const NetlessAppPresentation: NetlessApp<{}, {}, PresentationAppOptions,
|
|
|
540
547
|
}
|
|
541
548
|
}
|
|
542
549
|
|
|
543
|
-
const controller: PresentationController = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale }
|
|
550
|
+
const controller: PresentationController = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly, moveCamera, getOriginScale, getScale }
|
|
544
551
|
|
|
545
552
|
dispose.add(listen(window, 'message', (ev: MessageEvent<"@netless/_presentation_">) => {
|
|
546
553
|
if (ev.data === "@netless/_presentation_") {
|
package/src/scrollbar/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { makeDraggable } from "./Draggable";
|
|
|
4
4
|
import { debounce } from 'lodash';
|
|
5
5
|
|
|
6
6
|
export interface ScrollbarOption {
|
|
7
|
+
appId: string;
|
|
7
8
|
readonly?: boolean;
|
|
8
9
|
getPageSize: () => {
|
|
9
10
|
width: number;
|
|
@@ -20,14 +21,16 @@ export interface ScrollbarEventCallback {
|
|
|
20
21
|
onScrollbarDragEnd?: () => void;
|
|
21
22
|
onScrollbarDragX?: (x: number) => void;
|
|
22
23
|
onScrollbarDragY?: (y: number) => void;
|
|
23
|
-
onScrollCameraUpdated?: (originScale: number, scale: number) => void;
|
|
24
|
-
|
|
24
|
+
onScrollCameraUpdated?: (appid: string, originScale: number, scale: number) => void;
|
|
25
|
+
}
|
|
25
26
|
|
|
26
27
|
export class Scrollbar {
|
|
27
28
|
readonly namespace = "netless-app-presentation"
|
|
29
|
+
readonly appId: string;
|
|
28
30
|
private container: HTMLElement;
|
|
29
31
|
private scrollContainer: HTMLDivElement = document.createElement('div');
|
|
30
32
|
private option: ScrollbarOption = {
|
|
33
|
+
appId: '',
|
|
31
34
|
getPageSize: () => {
|
|
32
35
|
return {
|
|
33
36
|
width: 0,
|
|
@@ -55,6 +58,7 @@ export class Scrollbar {
|
|
|
55
58
|
this.scrollContainer.className = this.c('scrollbar-container');
|
|
56
59
|
this.container = container;
|
|
57
60
|
this.option = option;
|
|
61
|
+
this.appId = option.appId;
|
|
58
62
|
this.readonly = option.readonly || false;
|
|
59
63
|
this.view = view;
|
|
60
64
|
this.init();
|
|
@@ -89,7 +93,7 @@ export class Scrollbar {
|
|
|
89
93
|
this.scrollbarY.style.display = ratio === 1 ? 'none' : 'block';
|
|
90
94
|
this.scrollbarY.style.transform = `translateY(${scrollY}px)`;
|
|
91
95
|
}
|
|
92
|
-
this.option.scrollbarEventCallback?.onScrollCameraUpdated?.(originScale, scale);
|
|
96
|
+
this.option.scrollbarEventCallback?.onScrollCameraUpdated?.(this.appId, originScale, scale);
|
|
93
97
|
}, 50)
|
|
94
98
|
|
|
95
99
|
onDragStart = () => {
|