1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #4147 from kazuhitoyokoi/master-selection2subflow

Add node width and height to boundingBox
This commit is contained in:
Nick O'Leary 2023-04-28 15:23:02 +01:00 committed by GitHub
commit 00e7e4d43c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -663,24 +663,23 @@ RED.subflow = (function() {
var candidateOutputs = []; var candidateOutputs = [];
var candidateInputNodes = {}; var candidateInputNodes = {};
var boundingBox = [nodeList[0].x, var boundingBox = [nodeList[0].x-(nodeList[0].w/2),
nodeList[0].y, nodeList[0].y-(nodeList[0].h/2),
nodeList[0].x, nodeList[0].x+(nodeList[0].w/2),
nodeList[0].y]; nodeList[0].y+(nodeList[0].h/2)];
for (i=0;i<nodeList.length;i++) { for (i=0;i<nodeList.length;i++) {
n = nodeList[i]; n = nodeList[i];
nodes[n.id] = {n:n,outputs:{}}; nodes[n.id] = {n:n,outputs:{}};
boundingBox = [ boundingBox = [
Math.min(boundingBox[0],n.x), Math.min(boundingBox[0],n.x-(n.w/2)),
Math.min(boundingBox[1],n.y), Math.min(boundingBox[1],n.y-(n.h/2)),
Math.max(boundingBox[2],n.x), Math.max(boundingBox[2],n.x+(n.w/2)),
Math.max(boundingBox[3],n.y) Math.max(boundingBox[3],n.y+(n.h/2))
] ]
} }
var offsetX = snapToGrid(boundingBox[0] - 200); var offsetX = snapToGrid(boundingBox[0] - 140);
var offsetY = snapToGrid(boundingBox[1] - 80); var offsetY = snapToGrid(boundingBox[1] - 60);
var center = [ var center = [
snapToGrid((boundingBox[2]+boundingBox[0]) / 2), snapToGrid((boundingBox[2]+boundingBox[0]) / 2),