From 7a4f48e4fb083f876cdb34035b55ccddb37810c0 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 22 May 2023 16:26:38 +0100 Subject: [PATCH] Place subflow outputs/inputs relative to current view Fixes #4111 --- .../@node-red/editor-client/src/js/ui/subflow.js | 4 +++- .../@node-red/editor-client/src/js/ui/view.js | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js b/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js index ef9da4f96..da38e6054 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js @@ -46,7 +46,9 @@ RED.subflow = (function() { ''; function findAvailableSubflowIOPosition(subflow,isInput) { - var pos = {x:50,y:30}; + const scrollPos = RED.view.scroll() + const scaleFactor = RED.view.scale() + var pos = { x: (scrollPos[0]/scaleFactor)+50, y: (scrollPos[1]/scaleFactor)+30 }; if (!isInput) { pos.x += 110; } 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 2909e8182..f15c09f82 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 @@ -4359,6 +4359,7 @@ RED.view = (function() { this.__port__.setAttribute("transform","translate(-5,"+((d.h/2)-5)+")"); this.__outputOutput__.setAttribute("transform","translate(20,"+((d.h/2)-8)+")"); this.__outputNumber__.setAttribute("transform","translate(20,"+((d.h/2)+7)+")"); + this.__outputNumber__.textContent = d.i+1; } d.dirty = false; } @@ -6282,8 +6283,12 @@ RED.view = (function() { }) }, scroll: function(x,y) { - chart.scrollLeft(chart.scrollLeft()+x); - chart.scrollTop(chart.scrollTop()+y) + if (x !== undefined && y !== undefined) { + chart.scrollLeft(chart.scrollLeft()+x); + chart.scrollTop(chart.scrollTop()+y) + } else { + return [chart.scrollLeft(), chart.scrollTop()] + } }, clickNodeButton: function(n) { if (n._def.button) {