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

Align centre of nodes in vertical flow view

This commit is contained in:
Nick O'Leary 2019-11-21 21:57:30 +00:00
parent fc590c66c0
commit 61f42f9efa
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -1297,7 +1297,13 @@ RED.view = (function() {
if (snapGrid != d3.event.shiftKey && moving_set.length > 0) { if (snapGrid != d3.event.shiftKey && moving_set.length > 0) {
var gridOffset = [0,0]; var gridOffset = [0,0];
node = moving_set[0]; node = moving_set[0];
gridOffset[0] = node.n.x-(gridSize*Math.floor((node.n.x-node.n.w/2)/gridSize)+node.n.w/2); if (vertical) {
// Align to the centre point of the node
gridOffset[0] = node.n.x-(gridSize*Math.floor(node.n.x/gridSize));
} else {
// Align to the left edge of the node
gridOffset[0] = node.n.x-(gridSize*Math.floor((node.n.x-node.n.w/2)/gridSize)+node.n.w/2);
}
gridOffset[1] = node.n.y-(gridSize*Math.floor(node.n.y/gridSize)); gridOffset[1] = node.n.y-(gridSize*Math.floor(node.n.y/gridSize));
if (gridOffset[0] !== 0 || gridOffset[1] !== 0) { if (gridOffset[0] !== 0 || gridOffset[1] !== 0) {
for (i = 0; i<moving_set.length; i++) { for (i = 0; i<moving_set.length; i++) {