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

Add arrow-heads to links

This commit is contained in:
Nick O'Leary 2021-12-31 11:16:59 +00:00
parent 50cb074172
commit 5e9ff98c49
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -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);
}