Closed Yusufzai closed 3 years ago
Is there any update jero? about my query
Add before start
editor.dragEnd = function(e) {
if (e.type === "touchend") {
var e_pos_x = this.mouse_x;
var e_pos_y = this.mouse_y;
var ele_last = document.elementFromPoint(e_pos_x, e_pos_y);
} else {
var e_pos_x = e.clientX;
var e_pos_y = e.clientY;
var ele_last = e.target;
}
if(this.drag) {
if(this.pos_x_start != e_pos_x || this.pos_y_start != e_pos_y) {
this.dispatch('nodeMoved', this.ele_selected.id.slice(5));
}
}
if(this.drag_point) {
this.ele_selected.classList.remove("selected");
if(this.pos_x_start != e_pos_x || this.pos_y_start != e_pos_y) {
this.dispatch('rerouteMoved', this.ele_selected.parentElement.classList[2].slice(14));
}
}
if(this.editor_selected) {
this.canvas_x = this.canvas_x + (-(this.pos_x - e_pos_x));
this.canvas_y = this.canvas_y + (-(this.pos_y - e_pos_y));
this.editor_selected = false;
}
if(this.connection === true) {
if(ele_last.classList[0] === 'input' || (this.force_first_input && (ele_last.closest(".drawflow_content_node") != null || ele_last.classList[0] === 'drawflow-node'))) {
if(this.force_first_input && (ele_last.closest(".drawflow_content_node") != null || ele_last.classList[0] === 'drawflow-node')) {
if(ele_last.closest(".drawflow_content_node") != null) {
var input_id = ele_last.closest(".drawflow_content_node").parentElement.id;
} else {
var input_id = ele_last.id;
}
if(Object.keys(this.getNodeFromId(input_id.slice(5)).inputs).length === 0) {
var input_class = false;
} else {
var input_class = "input_1";
}
} else {
// Fix connection;
var input_id = ele_last.parentElement.parentElement.id;
var input_class = ele_last.classList[1];
}
var output_id = this.ele_selected.parentElement.parentElement.id;
var output_class = this.ele_selected.classList[1];
if( input_class !== false) {
if(this.container.querySelectorAll('.connection.node_in_'+input_id+'.node_out_'+output_id+'.'+output_class+'.'+input_class).length === 0) {
// Conection no exist save connection
this.connection_ele.classList.add("node_in_"+input_id);
this.connection_ele.classList.add("node_out_"+output_id);
this.connection_ele.classList.add(output_class);
this.connection_ele.classList.add(input_class);
var id_input = input_id.slice(5);
var id_output = output_id.slice(5);
this.drawflow.drawflow[this.module].data[id_output].outputs[output_class].connections.push( {"node": id_input, "output": input_class});
this.drawflow.drawflow[this.module].data[id_input].inputs[input_class].connections.push( {"node": id_output, "input": output_class});
this.updateConnectionNodes('node-'+id_output);
this.updateConnectionNodes('node-'+id_input);
this.dispatch('connectionCreated', { output_id: id_output, input_id: id_input, output_class: output_class, input_class: input_class});
} else {
this.dispatch('connectionCancel', true);
this.connection_ele.remove();
}
this.connection_ele = null;
} else {
// Connection exists Remove Connection;
this.dispatch('connectionCancel', true);
this.connection_ele.remove();
this.connection_ele = null;
}
} else {
// Remove Connection;
this.dispatch('connectionCancel', true);
this.connection_ele.remove();
this.connection_ele = null;
}
}
this.drag = false;
this.drag_point = false;
this.connection = false;
this.ele_selected = null;
this.editor_selected = false;
}
Only removed the function dragEnd
output_id !== input_id
View image:
Thanks, it worked successfully :)
Currently, the widgets are not able to connect with themself. How can I make that happen?