@netless/app-slide 0.2.88 → 0.2.90

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/app-slide",
3
- "version": "0.2.88",
3
+ "version": "0.2.90",
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.44",
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,14 +18,13 @@ 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 后, 重置为居中
25
25
  private translateX = 0.5;
26
26
  private translateY = 0.5;
27
27
 
28
- private lastTriggerTime = 0;
29
28
  private enableResize: boolean;
30
29
 
31
30
  constructor(
@@ -33,7 +32,7 @@ export class ResizableContainer {
33
32
  context: AppContext<Attributes, MagixEvents, AppOptions>,
34
33
  enableResize: boolean
35
34
  ) {
36
- this.enableResize = enableResize || true;
35
+ this.enableResize = enableResize;
37
36
  this.parent = parent;
38
37
  this.context = context;
39
38
  this.root = document.createElement('div');
@@ -53,8 +52,10 @@ export class ResizableContainer {
53
52
  this.scrollContainer.appendChild(this.container);
54
53
  this.root.appendChild(this.scrollContainer);
55
54
 
56
- // 初始化滚动条
57
- this.scrollBar = new ScrollBar(this.root, this);
55
+ if (this.enableResize) {
56
+ // 初始化滚动条
57
+ this.scrollBar = new ScrollBar(this.root, this);
58
+ }
58
59
 
59
60
  this.resizeObserver = new ResizeObserver(() => {
60
61
  this.updateResizableContainer();
@@ -96,15 +97,11 @@ export class ResizableContainer {
96
97
  };
97
98
 
98
99
  public updateResizableContainer() {
99
- if (Date.now() - this.lastTriggerTime < 50) {
100
- return;
101
- }
102
- this.lastTriggerTime = Date.now();
103
100
  const parentBounds = this.scrollContainer.getBoundingClientRect();
104
101
  this.container.style.width = `${parentBounds.width * this.scale}px`;
105
102
  this.container.style.height = `${parentBounds.height * this.scale}px`;
106
103
 
107
- if (this.whiteboardContainer) {
104
+ if (this.whiteboardContainer && this.enableResize) {
108
105
  const whiteboardBounds = this.whiteboardContainer.getBoundingClientRect();
109
106
  if (whiteboardBounds.width / whiteboardBounds.height > this.slideWidth / this.slideHeight) {
110
107
  // 裁剪两边
@@ -145,7 +142,7 @@ export class ResizableContainer {
145
142
  this.translateY = y;
146
143
  this.container.style.transform = `translate(${translateX}px, ${translateY}px)`;
147
144
  if (options.triggerScrollBar) {
148
- this.scrollBar.handleNormalizeTranslate(x, y);
145
+ this.scrollBar?.handleNormalizeTranslate(x, y);
149
146
  }
150
147
  if (options.triggerSync) {
151
148
  this.context.storage.setState({ translateX: this.translateX, translateY: this.translateY });
@@ -153,7 +150,7 @@ export class ResizableContainer {
153
150
  }
154
151
 
155
152
  public scaleContainer(applyScale: number) {
156
- if (Math.abs(this.scale - applyScale) < 0.001) {
153
+ if (Math.abs(this.scale - applyScale) < 0.001 || !this.enableResize) {
157
154
  return;
158
155
  }
159
156
  if (applyScale > 1.0) {
@@ -93,6 +93,9 @@ $namespace: $slide-namespace;
93
93
  align-items: center;
94
94
  padding: 0 16px;
95
95
  border-top: 1px solid #eeeef7;
96
+ -webkit-user-select: none;
97
+ -webkit-touch-callout: none;
98
+ -user-select: none;
96
99
  color: #191919;
97
100
  }
98
101