Skip to content

Commit

Permalink
Merge pull request #4147 from kazuhitoyokoi/master-selection2subflow
Browse files Browse the repository at this point in the history
Add node width and height to boundingBox
  • Loading branch information
knolleary committed Apr 28, 2023
2 parents ee43a84 + c30e57c commit 00e7e4d
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,24 +663,23 @@ RED.subflow = (function() {
var candidateOutputs = [];
var candidateInputNodes = {};

var boundingBox = [nodeList[0].x,
nodeList[0].y,
nodeList[0].x,
nodeList[0].y];
var boundingBox = [nodeList[0].x-(nodeList[0].w/2),
nodeList[0].y-(nodeList[0].h/2),
nodeList[0].x+(nodeList[0].w/2),
nodeList[0].y+(nodeList[0].h/2)];

for (i=0;i<nodeList.length;i++) {
n = nodeList[i];
nodes[n.id] = {n:n,outputs:{}};
boundingBox = [
Math.min(boundingBox[0],n.x),
Math.min(boundingBox[1],n.y),
Math.max(boundingBox[2],n.x),
Math.max(boundingBox[3],n.y)
Math.min(boundingBox[0],n.x-(n.w/2)),
Math.min(boundingBox[1],n.y-(n.h/2)),
Math.max(boundingBox[2],n.x+(n.w/2)),
Math.max(boundingBox[3],n.y+(n.h/2))
]
}
var offsetX = snapToGrid(boundingBox[0] - 200);
var offsetY = snapToGrid(boundingBox[1] - 80);

var offsetX = snapToGrid(boundingBox[0] - 140);
var offsetY = snapToGrid(boundingBox[1] - 60);

var center = [
snapToGrid((boundingBox[2]+boundingBox[0]) / 2),
Expand Down

0 comments on commit 00e7e4d

Please sign in to comment.