From fe8faf1a3b599a0d7d6c90205dff49e507c5ca4c Mon Sep 17 00:00:00 2001 From: M-Wicenec <wicenecmw@gmail.com> Date: Tue, 23 Jul 2024 14:08:51 +0800 Subject: [PATCH] fixed arrow direction when dragging an edge from an input port --- src/Errors.ts | 6 +----- src/GraphRenderer.ts | 8 +++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Errors.ts b/src/Errors.ts index 3833ce668..375b1509a 100644 --- a/src/Errors.ts +++ b/src/Errors.ts @@ -133,8 +133,4 @@ export namespace Errors Loading = "Loading", Graph = "Graph" } -} - - -//change data structure of each nodes, fields and edges and new logicalgraph is valid function to be {issue, validity}[] -// move to errors, use for nodes,fields and edges +} \ No newline at end of file diff --git a/src/GraphRenderer.ts b/src/GraphRenderer.ts index 787d46286..febb9e917 100644 --- a/src/GraphRenderer.ts +++ b/src/GraphRenderer.ts @@ -910,7 +910,13 @@ export class GraphRenderer { const srcField: Field = GraphRenderer.portDragSourcePort(); const destField: Field = null; - return GraphRenderer.createBezier(false,true, null, srcNodeRadius, destNodeRadius, {x:srcX, y:srcY}, {x:destX, y:destY}, srcField, destField, GraphRenderer.portDragSourcePortIsInput); + //if we are dragging from an input port well pass the dragSrcPort(the input port) as the destination of edge. this is so the flow arrow on the edge is point in the correct direction in terms of graph flow + if(GraphRenderer.portDragSourcePortIsInput){ + return GraphRenderer.createBezier(false,true, null, destNodeRadius, srcNodeRadius, {x:destX, y:destY}, {x:srcX, y:srcY}, destField, srcField, !GraphRenderer.portDragSourcePortIsInput); + }else{ + return GraphRenderer.createBezier(false,true, null, srcNodeRadius, destNodeRadius, {x:srcX, y:srcY}, {x:destX, y:destY}, srcField, destField, GraphRenderer.portDragSourcePortIsInput); + } + }, this); static getPathSuggestedEdge : ko.PureComputed<string> = ko.pureComputed(() => {