Closed fajardokarl closed 2 years ago
Hi @fajardokarl
You mean this?
Using the connectionCreated event we remove the previous connection. And we leave the new one.
Thank you for the reply @jerosoler. What I meant was like resetting the connection when you drag an input with the connection, It will detach.
Then the output connection will remain and other end will make the mouse pointer its end position again, like this.
I think this could work.
editor.on("clickEnd", (e) => {
if(e.target.classList[0] === "input") {
const nodeId = e.target.closest(".drawflow-node").id.slice(5);
const nodeInfo = editor.getNodeFromId(nodeId);
if(nodeInfo.inputs[e.target.classList[1]].connections.length > 0) {
const removeConnectionInfo = nodeInfo.inputs[e.target.classList[1]].connections[0];
editor.removeSingleConnection(removeConnectionInfo.node, nodeInfo.id, removeConnectionInfo.input, e.target.classList[1]);
var evt = new MouseEvent("mousedown", {
view: window,
bubbles: true,
cancelable: false,
});
editor.container.querySelector(`#node-${removeConnectionInfo.node} .outputs .output.${removeConnectionInfo.input}`).dispatchEvent(evt);
}
}
});
It works, thank you so much. I think this could be a good additional feature for the library in the future version. Cheers.
Hi, been using this for a project and it's been good. But a requirement was added on our side of the project. Is there a way to change the input? In our case, we need to make the connection detached when we draw the input on a node that has a connection.