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

Only recalculate group label offsets when needed

This commit is contained in:
Nick O'Leary 2020-09-03 13:49:42 +01:00
parent 716dc781e4
commit 02c20e97b7
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -4437,6 +4437,7 @@ RED.view = (function() {
} }
if (d.dirty || dirtyGroups[d.id]) { if (d.dirty || dirtyGroups[d.id]) {
var g = d3.select(this); var g = d3.select(this);
var recalculateLabelOffsets = false;
if (d.nodes.length > 0) { if (d.nodes.length > 0) {
// If the group was just moved, all of its contents was // If the group was just moved, all of its contents was
// also moved - so no need to recalculate its bounding box // also moved - so no need to recalculate its bounding box
@ -4465,6 +4466,7 @@ RED.view = (function() {
d.y = minY; d.y = minY;
d.w = maxX - minX; d.w = maxX - minX;
d.h = maxY - minY; d.h = maxY - minY;
recalculateLabelOffsets = true;
// if set explicitly to false, this group has just been // if set explicitly to false, this group has just been
// imported so needed this initial resize calculation. // imported so needed this initial resize calculation.
// Now that's done, delete the flag so the normal // Now that's done, delete the flag so the normal
@ -4478,7 +4480,9 @@ RED.view = (function() {
} else { } else {
d.w = 40; d.w = 40;
d.h = 40; d.h = 40;
recalculateLabelOffsets = true;
} }
if (recalculateLabelOffsets) {
if (!d.minWidth) { if (!d.minWidth) {
if (d.style.label && d.name) { if (d.style.label && d.name) {
var labelParts = getLabelParts(d.name||"","red-ui-flow-group-label"); var labelParts = getLabelParts(d.name||"","red-ui-flow-group-label");
@ -4503,6 +4507,7 @@ RED.view = (function() {
} }
} }
} }
}
g.attr("transform","translate("+d.x+","+d.y+")") g.attr("transform","translate("+d.x+","+d.y+")")
g.selectAll(".red-ui-flow-group-outline") g.selectAll(".red-ui-flow-group-outline")