From 3343c64961638179993b5d38ad22779dc7c7e28d Mon Sep 17 00:00:00 2001 From: Jero Soler Date: Thu, 28 Apr 2022 17:16:52 +0200 Subject: [PATCH] Fix rerorute add and remove points --- src/drawflow.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/drawflow.js b/src/drawflow.js index 891dc25..977eff5 100644 --- a/src/drawflow.js +++ b/src/drawflow.js @@ -1103,8 +1103,8 @@ export default class Drawflow { } if(this.reroute_fix_curvature) { - //console.log(position_add_array_point) - if(position_add_array_point > 0) { + + if(position_add_array_point > 0 || this.drawflow.drawflow[this.module].data[nodeId].outputs[output_class].connections[searchConnection].points !== []) { this.drawflow.drawflow[this.module].data[nodeId].outputs[output_class].connections[searchConnection].points.splice(position_add_array_point, 0, { pos_x: pos_x, pos_y: pos_y }); } else { this.drawflow.drawflow[this.module].data[nodeId].outputs[output_class].connections[searchConnection].points.push({ pos_x: pos_x, pos_y: pos_y }); @@ -1128,22 +1128,21 @@ export default class Drawflow { const output_class = ele.parentElement.classList[3]; const input_class = ele.parentElement.classList[4]; - - let numberPointPosition = Array.from(ele.parentElement.children).indexOf(ele)-1; - + let numberPointPosition = Array.from(ele.parentElement.children).indexOf(ele); const nodeId = nodeUpdate.slice(5); const searchConnection = this.drawflow.drawflow[this.module].data[nodeId].outputs[output_class].connections.findIndex(function(item,i) { return item.node === nodeUpdateIn && item.output === input_class; }); if(this.reroute_fix_curvature) { - const numberMainPath = ele.parentElement.querySelectorAll(".main-path").length ele.parentElement.children[numberMainPath-1].remove(); numberPointPosition -= numberMainPath; if(numberPointPosition < 0) { numberPointPosition = 0; } + } else { + numberPointPosition--; } this.drawflow.drawflow[this.module].data[nodeId].outputs[output_class].connections[searchConnection].points.splice(numberPointPosition,1);