Skip to content

Commit

Permalink
Fix rerorute add and remove points
Browse files Browse the repository at this point in the history
  • Loading branch information
jerosoler committed Apr 28, 2022
1 parent 4941d25 commit 3343c64
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/drawflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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);

Expand Down

0 comments on commit 3343c64

Please sign in to comment.