Browse Source

Plugin ftgpm-edit.js: Fixed bug(s)

Joeri Exelmans 4 years ago
parent
commit
f14b65340d
1 changed files with 6 additions and 5 deletions
  1. 6 5
      src/main/webapp/plugins/cdf/ftgpm-edit.js

+ 6 - 5
src/main/webapp/plugins/cdf/ftgpm-edit.js

@@ -243,10 +243,10 @@ Draw.loadPlugin(function(ui) {
       }
     }
 
-    function closestBorder(cell, parentGeometry) {
+    function closestBorder(cellGeometry, parentGeometry) {
       // Coordinates are relative to topleft corner of parent shape
-      const {x,y, width, height} = cell.geometry;
-      // Center of dragged shape
+      const {x,y, width, height} = cellGeometry;
+      // Center of cell
       const cX = x + width/2;
       const cY = y + height/2;
 
@@ -299,7 +299,7 @@ Draw.loadPlugin(function(ui) {
       for (const cell of cells) {
         const parentGeometry = getPortParentGeometry(cell);
         if (parentGeometry) {
-          const border = closestBorder(cell, parentGeometry);
+          const border = closestBorder(cell.geometry, parentGeometry);
           moveToBorder(cell.geometry, parentGeometry, border);
         }
       }
@@ -330,7 +330,8 @@ Draw.loadPlugin(function(ui) {
 
           for (const cell of parent.children) {
             const parentGeometry = getPortParentGeometry(cell);
-            const border = closestBorder(cell, oldParentGeometry);
+            if (!parentGeometry) continue;
+            const border = closestBorder(cell.geometry, oldParentGeometry);
             const newGeometry = cell.geometry.clone();
             moveToBorder(newGeometry, parentGeometry, border);