@netless/app-slide 0.2.88 → 0.2.89
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 +4 -4
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +12 -8
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +4 -4
- package/dist/main.iife.js.map +1 -1
- package/package.json +2 -2
- package/src/DocsViewer/ResizableContainer.ts +9 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/app-slide",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.89",
|
|
4
4
|
"main": "dist/main.cjs.js",
|
|
5
5
|
"module": "dist/main.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"README-zh.md"
|
|
11
11
|
],
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@netless/slide": "1.4.
|
|
13
|
+
"@netless/slide": "1.4.45",
|
|
14
14
|
"@types/color-string": "^1.5.2",
|
|
15
15
|
"color-string": "^1.9.1",
|
|
16
16
|
"jspdf": "2.5.1",
|
|
@@ -18,7 +18,7 @@ export class ResizableContainer {
|
|
|
18
18
|
private resizeObserver: ResizeObserver | null = null;
|
|
19
19
|
private slideWidth = 1;
|
|
20
20
|
private slideHeight = 1;
|
|
21
|
-
private scrollBar: ScrollBar;
|
|
21
|
+
private scrollBar: ScrollBar | null = null;
|
|
22
22
|
private context: AppContext<Attributes, MagixEvents, AppOptions>;
|
|
23
23
|
|
|
24
24
|
// 每次 scale 后, 重置为居中
|
|
@@ -33,7 +33,7 @@ export class ResizableContainer {
|
|
|
33
33
|
context: AppContext<Attributes, MagixEvents, AppOptions>,
|
|
34
34
|
enableResize: boolean
|
|
35
35
|
) {
|
|
36
|
-
this.enableResize = enableResize
|
|
36
|
+
this.enableResize = enableResize;
|
|
37
37
|
this.parent = parent;
|
|
38
38
|
this.context = context;
|
|
39
39
|
this.root = document.createElement('div');
|
|
@@ -53,8 +53,10 @@ export class ResizableContainer {
|
|
|
53
53
|
this.scrollContainer.appendChild(this.container);
|
|
54
54
|
this.root.appendChild(this.scrollContainer);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
if (this.enableResize) {
|
|
57
|
+
// 初始化滚动条
|
|
58
|
+
this.scrollBar = new ScrollBar(this.root, this);
|
|
59
|
+
}
|
|
58
60
|
|
|
59
61
|
this.resizeObserver = new ResizeObserver(() => {
|
|
60
62
|
this.updateResizableContainer();
|
|
@@ -104,7 +106,7 @@ export class ResizableContainer {
|
|
|
104
106
|
this.container.style.width = `${parentBounds.width * this.scale}px`;
|
|
105
107
|
this.container.style.height = `${parentBounds.height * this.scale}px`;
|
|
106
108
|
|
|
107
|
-
if (this.whiteboardContainer) {
|
|
109
|
+
if (this.whiteboardContainer && this.enableResize) {
|
|
108
110
|
const whiteboardBounds = this.whiteboardContainer.getBoundingClientRect();
|
|
109
111
|
if (whiteboardBounds.width / whiteboardBounds.height > this.slideWidth / this.slideHeight) {
|
|
110
112
|
// 裁剪两边
|
|
@@ -145,7 +147,7 @@ export class ResizableContainer {
|
|
|
145
147
|
this.translateY = y;
|
|
146
148
|
this.container.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
147
149
|
if (options.triggerScrollBar) {
|
|
148
|
-
this.scrollBar
|
|
150
|
+
this.scrollBar?.handleNormalizeTranslate(x, y);
|
|
149
151
|
}
|
|
150
152
|
if (options.triggerSync) {
|
|
151
153
|
this.context.storage.setState({ translateX: this.translateX, translateY: this.translateY });
|
|
@@ -153,7 +155,7 @@ export class ResizableContainer {
|
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
public scaleContainer(applyScale: number) {
|
|
156
|
-
if (Math.abs(this.scale - applyScale) < 0.001) {
|
|
158
|
+
if (Math.abs(this.scale - applyScale) < 0.001 || !this.enableResize) {
|
|
157
159
|
return;
|
|
158
160
|
}
|
|
159
161
|
if (applyScale > 1.0) {
|