mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Improve performance of moving groups
This commit is contained in:
parent
16c26d8098
commit
758f44e25f
@ -1339,6 +1339,7 @@ RED.view = (function() {
|
||||
node.n.y = mousePos[1]+node.dy;
|
||||
node.n.dirty = true;
|
||||
if (node.n.type === "group") {
|
||||
node.n.groupMoved = true;
|
||||
RED.group.markDirty(node.n);
|
||||
minX = Math.min(node.n.x-5,minX);
|
||||
minY = Math.min(node.n.y-5,minY);
|
||||
@ -1711,6 +1712,7 @@ RED.view = (function() {
|
||||
if (mouse_mode === RED.state.SELECTING_NODE && selectNodesOptions.single) {
|
||||
return;
|
||||
}
|
||||
clearSelection();
|
||||
exitActiveGroup();
|
||||
activeGroups.forEach(function(g) {
|
||||
if (!g.g) {
|
||||
@ -2912,7 +2914,7 @@ RED.view = (function() {
|
||||
} else {
|
||||
dblClickPrimed = false;
|
||||
}
|
||||
selectGroup(nodeGroup, !activeGroup);
|
||||
selectGroup(nodeGroup, !activeGroup, !!groupNodeSelectPrimed);
|
||||
if (activeGroup) {
|
||||
mousedown_node.selected = true;
|
||||
moving_set.push({n:mousedown_node});
|
||||
@ -4301,7 +4303,9 @@ RED.view = (function() {
|
||||
})
|
||||
}
|
||||
group[0].reverse();
|
||||
var groupOpCount=0;
|
||||
group.each(function(d,i) {
|
||||
groupOpCount++
|
||||
if (d.resize) {
|
||||
d.minWidth = 0;
|
||||
delete d.resize;
|
||||
@ -4309,12 +4313,16 @@ RED.view = (function() {
|
||||
if (d.dirty || dirtyGroups[d.id]) {
|
||||
var g = d3.select(this);
|
||||
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
|
||||
if (!d.groupMoved) {
|
||||
var minX = Number.POSITIVE_INFINITY;
|
||||
var minY = Number.POSITIVE_INFINITY;
|
||||
var maxX = 0;
|
||||
var maxY = 0;
|
||||
var margin = 26;
|
||||
d.nodes.forEach(function(n) {
|
||||
groupOpCount++
|
||||
if (n.type !== "group") {
|
||||
minX = Math.min(minX,n.x-n.w/2-margin-((n._def.button && n._def.align!=="right")?20:0));
|
||||
minY = Math.min(minY,n.y-n.h/2-margin);
|
||||
@ -4332,6 +4340,9 @@ RED.view = (function() {
|
||||
d.y = minY;
|
||||
d.w = maxX - minX;
|
||||
d.h = maxY - minY;
|
||||
} else {
|
||||
delete d.groupMoved;
|
||||
}
|
||||
} else {
|
||||
d.w = 40;
|
||||
d.h = 40;
|
||||
|
Loading…
Reference in New Issue
Block a user