@netless/window-manager 1.0.13-test.10 → 1.0.13-test.11

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/window-manager",
3
- "version": "1.0.13-test.10",
3
+ "version": "1.0.13-test.11",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
@@ -37,6 +37,7 @@ export class MainViewProxy {
37
37
  this.startListenWritableChange();
38
38
  });
39
39
  const playgroundSizeChangeListener = () => {
40
+ this.refreshScreenSizeIfStale();
40
41
  this.playgroundSizeChangeListenerLocalConsole.log(
41
42
  JSON.stringify(this.mainView.camera),
42
43
  JSON.stringify(this.mainView.size),
@@ -109,6 +110,24 @@ export class MainViewProxy {
109
110
  this.moveCamera(this.mainViewCamera);
110
111
  }
111
112
 
113
+ private refreshScreenSizeIfStale() {
114
+ const element = this.mainView.divElement;
115
+ if (!element) return;
116
+
117
+ const { width, height } = element.getBoundingClientRect();
118
+ if (width <= 0 || height <= 0) return;
119
+
120
+ const { width: viewWidth, height: viewHeight } = this.mainView.size;
121
+ if (Math.abs(viewWidth - width) > 0.5 || Math.abs(viewHeight - height) > 0.5) {
122
+ const resizableView = this.mainView as View & { resizeScreen?: () => void };
123
+ console.log("[window-manager] forceResizeScreen stale size" + JSON.stringify({
124
+ viewSize: this.mainView.size,
125
+ domSize: { width, height },
126
+ }));
127
+ resizableView.resizeScreen?.();
128
+ }
129
+ }
130
+
112
131
  public start() {
113
132
  console.log("[window-manager] start " + JSON.stringify(this.mainViewSize));
114
133
  this.sizeChangeHandler(this.mainViewSize);
@@ -261,6 +280,14 @@ export class MainViewProxy {
261
280
  private _syncMainViewTimer = 0;
262
281
  private onCameraOrSizeUpdated = () => {
263
282
  console.log("[window-manager] onCameraOrSizeUpdated " + JSON.stringify(this.cameraState));
283
+ if(this.mainView.divElement){
284
+ const children = this.mainView.divElement.children;
285
+ console.log("[window-manager] onCameraOrSizeUpdated " + this.mainView.divElement.getBoundingClientRect());
286
+ const child = children[0];
287
+ if (child) {
288
+ console.log("[window-manager] child" + JSON.stringify(child.getBoundingClientRect()));
289
+ }
290
+ }
264
291
  callbacks.emit("cameraStateChange", this.cameraState);
265
292
  // sdk >= 2.16.43 的 syncMainView() 可以写入当前 main view 的 camera, 以修复复制粘贴元素的位置
266
293
  // 注意到这个操作会发送信令,应当避免频繁调用