@netless/window-manager 1.0.0-canary.40 → 1.0.0-canary.41

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.
@@ -126,6 +126,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
126
126
  private _pageState?;
127
127
  private boxManager?;
128
128
  private static params?;
129
+ private cameraUpdating;
129
130
  containerSizeRatio: number;
130
131
  constructor(context: InvisiblePluginContext);
131
132
  static mount(params: MountParams): Promise<WindowManager>;
@@ -231,7 +232,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
231
232
  * 关闭 APP
232
233
  */
233
234
  closeApp(appId: string): Promise<void>;
234
- moveCamera: import("lodash").DebouncedFunc<(camera: Partial<Camera> & {
235
+ moveCamera: import("lodash").DebouncedFuncLeading<(camera: Partial<Camera> & {
235
236
  animationMode?: AnimationMode;
236
237
  }) => void>;
237
238
  convertToPointInWorld(point: Point): Point;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.40",
3
+ "version": "1.0.0-canary.41",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
package/src/index.ts CHANGED
@@ -184,6 +184,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
184
184
  private boxManager?: BoxManager;
185
185
  private static params?: MountParams;
186
186
 
187
+ private cameraUpdating = 0;
188
+
187
189
  public containerSizeRatio = WindowManager.containerSizeRatio;
188
190
 
189
191
  constructor(context: InvisiblePluginContext) {
@@ -806,6 +808,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
806
808
  }
807
809
 
808
810
  public moveCamera = debounce((camera: Partial<Camera> & { animationMode?: AnimationMode } ): void => {
811
+ console.log("moveCamera", performance.now());
809
812
  const mainViewCamera = { ...this.mainView.camera };
810
813
  const nextCamera = { ...mainViewCamera, ...camera };
811
814
  if (isEqual(nextCamera, mainViewCamera)) return;
@@ -831,15 +834,26 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
831
834
  this.mainView.moveCamera(camera);
832
835
  }
833
836
  this.appManager.dispatchInternalEvent(Events.MoveCamera, camera);
834
- setTimeout(() => {
835
- if (!this.appManager) return;
836
- this.appManager.mainViewProxy.storeCamera({
837
- id: this.appManager.uid,
838
- ...nextCamera
839
- });
840
- }, 200);
837
+ const onCameraUpdated = () => {
838
+ if (this.cameraUpdating) {
839
+ clearTimeout(this.cameraUpdating);
840
+ }
841
+ this.cameraUpdating = setTimeout(() => {
842
+ this.mainView.callbacks.off("onCameraUpdated", onCameraUpdated);
843
+ clearTimeout(this.cameraUpdating);
844
+ this.cameraUpdating = 0;
845
+ if (!this.appManager) return;
846
+ this.appManager.mainViewProxy.storeCamera({
847
+ id: this.appManager.uid,
848
+ ...nextCamera
849
+ });
850
+ }, 50);
851
+ }
852
+ this.mainView.callbacks.off("onCameraUpdated", onCameraUpdated);
853
+ this.mainView.callbacks.on("onCameraUpdated", onCameraUpdated);
854
+
841
855
  }
842
- }, 200);
856
+ }, 400, { leading: true });
843
857
 
844
858
  public convertToPointInWorld(point: Point): Point {
845
859
  return this.mainView.convertToPointInWorld(point);