From 61f42f9efaed902d88c37ed1e74c44c4655499ff Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 21 Nov 2019 21:57:30 +0000 Subject: [PATCH] Align centre of nodes in vertical flow view --- .../@node-red/editor-client/src/js/ui/view.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index 87dd69738..10933a574 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -1297,7 +1297,13 @@ RED.view = (function() { if (snapGrid != d3.event.shiftKey && moving_set.length > 0) { var gridOffset = [0,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)); if (gridOffset[0] !== 0 || gridOffset[1] !== 0) { for (i = 0; i