Jelajahi Sumber

Fix double click on nme header

David Catuhe 5 tahun lalu
induk
melakukan
527ad7b5fc
1 mengubah file dengan 25 tambahan dan 13 penghapusan
  1. 25 13
      nodeEditor/src/diagram/graphFrame.ts

+ 25 - 13
nodeEditor/src/diagram/graphFrame.ts

@@ -48,10 +48,13 @@ export class GraphFrame {
         }
         }
 
 
         this._isCollapsed = value;
         this._isCollapsed = value;
+        this._ownerCanvas._frameIsMoving = true;
 
 
         // Need to delegate the outside ports to the frame
         // Need to delegate the outside ports to the frame
         if (value) {
         if (value) {
             this.element.classList.add("collapsed");
             this.element.classList.add("collapsed");
+                        
+            this._moveFrame((this.width - 200) / 2, 0);
 
 
             for (var node of this._nodes) {
             for (var node of this._nodes) {
                 node.isVisible = false;
                 node.isVisible = false;
@@ -95,7 +98,7 @@ export class GraphFrame {
                     } else {
                     } else {
                         this._createInputPort(port, node);
                         this._createInputPort(port, node);
                     }
                     }
-                }
+                }               
             }
             }
         } else {
         } else {
             this.element.classList.remove("collapsed");
             this.element.classList.remove("collapsed");
@@ -117,7 +120,12 @@ export class GraphFrame {
             for (var node of this._nodes) {
             for (var node of this._nodes) {
                 node.isVisible = true;
                 node.isVisible = true;
             }
             }
+                        
+            this._moveFrame(-(this.width - 200) / 2, 0);
         }
         }
+
+        this.cleanAccumulation();
+        this._ownerCanvas._frameIsMoving = false;
     }
     }
 
 
     public get nodes() {
     public get nodes() {
@@ -295,6 +303,10 @@ export class GraphFrame {
     public cleanAccumulation() {
     public cleanAccumulation() {
         this.x = this._gridAlignedX;
         this.x = this._gridAlignedX;
         this.y = this._gridAlignedY;
         this.y = this._gridAlignedY;
+
+        for (var selectedNode of this._nodes) {
+            selectedNode.cleanAccumulation();
+        }        
     }
     }
 
 
     private _onDown(evt: PointerEvent) {
     private _onDown(evt: PointerEvent) {
@@ -312,10 +324,6 @@ export class GraphFrame {
     private _onUp(evt: PointerEvent) {
     private _onUp(evt: PointerEvent) {
         evt.stopPropagation();
         evt.stopPropagation();
 
 
-        for (var selectedNode of this._nodes) {
-            selectedNode.cleanAccumulation();
-        }
-
         this.cleanAccumulation();
         this.cleanAccumulation();
         this._mouseStartPointX = null;
         this._mouseStartPointX = null;
         this._mouseStartPointY = null;
         this._mouseStartPointY = null;
@@ -324,6 +332,16 @@ export class GraphFrame {
         this._ownerCanvas._frameIsMoving = false;
         this._ownerCanvas._frameIsMoving = false;
     }
     }
 
 
+    private _moveFrame(offsetX: number, offsetY: number) {
+        for (var selectedNode of this._nodes) {
+            selectedNode.x += offsetX;
+            selectedNode.y += offsetY;
+        }
+
+        this.x += offsetX;
+        this.y += offsetY;
+    }
+
     private _onMove(evt: PointerEvent) {
     private _onMove(evt: PointerEvent) {
         if (this._mouseStartPointX === null || this._mouseStartPointY === null || evt.ctrlKey) {
         if (this._mouseStartPointX === null || this._mouseStartPointY === null || evt.ctrlKey) {
             return;
             return;
@@ -332,16 +350,10 @@ export class GraphFrame {
         let newX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
         let newX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
         let newY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
         let newY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
 
 
-        for (var selectedNode of this._nodes) {
-            selectedNode.x += newX;
-            selectedNode.y += newY;
-        }
-
-        this.x += newX;
-        this.y += newY;
+        this._moveFrame(newX, newY);
 
 
         this._mouseStartPointX = evt.clientX;
         this._mouseStartPointX = evt.clientX;
-        this._mouseStartPointY = evt.clientY;   
+        this._mouseStartPointY = evt.clientY; 
 
 
         evt.stopPropagation();
         evt.stopPropagation();
     }
     }