Merge pull request #4183 from node-red/4111-subflow-node-position

Place subflow outputs/inputs relative to current view
This commit is contained in:
Nick O'Leary 2023-05-22 16:46:56 +01:00 committed by GitHub
commit 0f5cf1d51c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -46,7 +46,9 @@ RED.subflow = (function() {
'</script>';
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;
}

View File

@ -4374,6 +4374,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;
}
@ -6296,8 +6297,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) {