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:
parent
716dc781e4
commit
02c20e97b7
@ -4437,6 +4437,7 @@ RED.view = (function() {
|
||||
}
|
||||
if (d.dirty || dirtyGroups[d.id]) {
|
||||
var g = d3.select(this);
|
||||
var recalculateLabelOffsets = false;
|
||||
if (d.nodes.length > 0) {
|
||||
// If the group was just moved, all of its contents was
|
||||
// also moved - so no need to recalculate its bounding box
|
||||
@ -4465,6 +4466,7 @@ RED.view = (function() {
|
||||
d.y = minY;
|
||||
d.w = maxX - minX;
|
||||
d.h = maxY - minY;
|
||||
recalculateLabelOffsets = true;
|
||||
// if set explicitly to false, this group has just been
|
||||
// imported so needed this initial resize calculation.
|
||||
// Now that's done, delete the flag so the normal
|
||||
@ -4478,28 +4480,31 @@ RED.view = (function() {
|
||||
} else {
|
||||
d.w = 40;
|
||||
d.h = 40;
|
||||
recalculateLabelOffsets = true;
|
||||
}
|
||||
if (!d.minWidth) {
|
||||
if (d.style.label && d.name) {
|
||||
var labelParts = getLabelParts(d.name||"","red-ui-flow-group-label");
|
||||
d.minWidth = labelParts.width + 8;
|
||||
d.labels = labelParts.lines;
|
||||
} else {
|
||||
d.minWidth = 40;
|
||||
d.labels = [];
|
||||
if (recalculateLabelOffsets) {
|
||||
if (!d.minWidth) {
|
||||
if (d.style.label && d.name) {
|
||||
var labelParts = getLabelParts(d.name||"","red-ui-flow-group-label");
|
||||
d.minWidth = labelParts.width + 8;
|
||||
d.labels = labelParts.lines;
|
||||
} else {
|
||||
d.minWidth = 40;
|
||||
d.labels = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
d.w = Math.max(d.minWidth,d.w);
|
||||
if (d.style.label && d.labels.length > 0) {
|
||||
var labelPos = d.style["label-position"] || "nw";
|
||||
var h = (d.labels.length-1) * 16;
|
||||
if (labelPos[0] === "s") {
|
||||
h += 8;
|
||||
}
|
||||
d.h += h;
|
||||
if (labelPos[0] === "n") {
|
||||
if (d.nodes.length > 0) {
|
||||
d.y -= h;
|
||||
d.w = Math.max(d.minWidth,d.w);
|
||||
if (d.style.label && d.labels.length > 0) {
|
||||
var labelPos = d.style["label-position"] || "nw";
|
||||
var h = (d.labels.length-1) * 16;
|
||||
if (labelPos[0] === "s") {
|
||||
h += 8;
|
||||
}
|
||||
d.h += h;
|
||||
if (labelPos[0] === "n") {
|
||||
if (d.nodes.length > 0) {
|
||||
d.y -= h;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user