From eb1fdea49d6d26d265e01139eb828f2eec10e02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrkan=20G=C3=BCran?= Date: Tue, 29 Nov 2022 01:21:01 +0100 Subject: [PATCH] Increased the performance of rotating algorithm --- .../src/modules/flowchart/shapes.ts | 8 +++--- .../src/utils/graph.ts | 26 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/designer/elsa-workflows-designer/src/modules/flowchart/shapes.ts b/src/designer/elsa-workflows-designer/src/modules/flowchart/shapes.ts index dc0bfcdcd..1d8755393 100644 --- a/src/designer/elsa-workflows-designer/src/modules/flowchart/shapes.ts +++ b/src/designer/elsa-workflows-designer/src/modules/flowchart/shapes.ts @@ -118,7 +118,7 @@ ActivityNodeShape.config({ position: 'left', attrs: { circle: { - r: 6, + r: 5, magnet: true, stroke: '#3c82f6', strokeWidth: 2, @@ -139,7 +139,7 @@ ActivityNodeShape.config({ position: 'right', attrs: { circle: { - r: 6, + r: 5, magnet: true, stroke: '#3c82f6', strokeWidth: 2, @@ -160,7 +160,7 @@ ActivityNodeShape.config({ position: 'top', attrs: { circle: { - r: 6, + r: 5, magnet: true, stroke: '#3c82f6', strokeWidth: 2, @@ -181,7 +181,7 @@ ActivityNodeShape.config({ position: 'bottom', attrs: { circle: { - r: 6, + r: 5, magnet: true, stroke: '#3c82f6', strokeWidth: 2, diff --git a/src/designer/elsa-workflows-designer/src/utils/graph.ts b/src/designer/elsa-workflows-designer/src/utils/graph.ts index cb8478163..faff7a9b9 100644 --- a/src/designer/elsa-workflows-designer/src/utils/graph.ts +++ b/src/designer/elsa-workflows-designer/src/utils/graph.ts @@ -9,7 +9,7 @@ export function adjustPortMarkupByNode(node: Node) { if(port.type == 'out'){ node.setPortProp(port.id, "attrs", { circle: { - r: 6, + r: 5, magnet: true, stroke: '#fff', strokeWidth: 2, @@ -24,7 +24,7 @@ export function adjustPortMarkupByNode(node: Node) { else { node.setPortProp(port.id, "attrs", { circle: { - r: 6, + r: 5, magnet: true, stroke: '#3c82f6', strokeWidth: 2, @@ -60,7 +60,7 @@ function findMatchingPortForEdge(node: Node, position: string, } function getPortNameByPortId(portId: string) { - return portId.split('_')[1] == 'null' ? null : portId.split('_')[1]; + return portId.split('_')[1] == 'null' ? null : portId.split('_')[1] == 'In' ? null : portId.split('_')[1]; } function updatePortsAndEdges( @@ -86,17 +86,19 @@ function updatePortsAndEdgesOfNodeCouple(graph: Graph, sourceNode: Node p.type == "out" && getPortNameByPortId(p.id) == getPortNameByPortId(edge.data.sourcePort)); const targetNodePort = targetNode.getPort(edge.data.targetPort) ?? targetNode.getPorts().find(p => p.type == "in"); - graph.removeEdge(edge); + if(sourceNodePort.position != newSourceNodePosition || targetNodePort.position != newTargetNodePosition) { + graph.removeEdge(edge); - const newSourceNodePortId = updatePort(graph, sourceNode, sourceNodePort, newSourceNodePosition); - const newTargetNodePortId = updatePort(graph, targetNode, targetNodePort, newTargetNodePosition); + const newSourceNodePortId = updatePort(graph, sourceNode, sourceNodePort, newSourceNodePosition); + const newTargetNodePortId = updatePort(graph, targetNode, targetNodePort, newTargetNodePosition); - graph.addEdge(createEdge({ - source: sourceNode.id, - target: targetNode.id, - sourcePort: newSourceNodePortId ?? sourceNodePort.id, - targetPort: newTargetNodePortId ?? targetNodePort.id - })); + graph.addEdge(createEdge({ + source: sourceNode.id, + target: targetNode.id, + sourcePort: newSourceNodePortId ?? sourceNodePort.id, + targetPort: newTargetNodePortId ?? targetNodePort.id + })); + } } }