From 5e9ff98c490614114313c58ad0700ae606094bb3 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 31 Dec 2021 11:16:59 +0000 Subject: [PATCH] Add arrow-heads to links --- .../@node-red/editor-client/src/js/ui/view.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 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 50ef315b3..8a651037a 100755 --- 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 @@ -835,8 +835,9 @@ RED.view = (function() { } else { scale = 0.4-0.2*(Math.max(0,(node_width-Math.min(Math.abs(dx),Math.abs(dy)))/node_width)); } + var result; if (dx*sc > 0) { - return "M "+origX+" "+origY+ + result = "M "+origX+" "+origY+ " C "+(origX+sc*(node_width*scale))+" "+(origY+scaleY*node_height)+" "+ (destX-sc*(scale)*node_width)+" "+(destY-scaleY*node_height)+" "+ destX+" "+destY @@ -877,7 +878,7 @@ RED.view = (function() { } cp[2][0] = topX; } - return "M "+origX+" "+origY+ + result = "M "+origX+" "+origY+ " C "+ cp[0][0]+" "+cp[0][1]+" "+ cp[1][0]+" "+cp[1][1]+" "+ @@ -892,6 +893,7 @@ RED.view = (function() { cp[4][0]+" "+cp[4][1]+" "+ destX+" "+destY } + return result; } function addNode(type,x,y) { @@ -4605,18 +4607,14 @@ RED.view = (function() { d.y1 = d.source.y+y; d.x2 = d.target.x-d.target.w/2; d.y2 = d.target.y; - - // return "M "+d.x1+" "+d.y1+ - // " C "+(d.x1+scale*node_width)+" "+(d.y1+scaleY*node_height)+" "+ - // (d.x2-scale*node_width)+" "+(d.y2-scaleY*node_height)+" "+ - // d.x2+" "+d.y2; - var path = generateLinkPath(d.x1,d.y1,d.x2,d.y2,1); + var targetOffset = d.link?16:11 + var path = generateLinkPath(d.x1+5,d.y1,d.x2-targetOffset,d.y2,1); if (/NaN/.test(path)) { path = "" } this.__pathBack__.setAttribute("d",path); this.__pathOutline__.setAttribute("d",path); - this.__pathLine__.setAttribute("d",path); + this.__pathLine__.setAttribute("d",path + "m0 0, l 0 -2 l 3 2 l -3 2 z"); this.__pathLine__.classList.toggle("red-ui-flow-node-disabled",!!(d.source.d || d.target.d)); this.__pathLine__.classList.toggle("red-ui-flow-subflow-link", !d.link && activeSubflow); }