Open dotrungit91 opened 2 years ago
Use event connectionCreated
to detec connection and add css class to line.
In the event you can see what types of nodes they are with getNodeFromId
@jerosoler
I render connection by data. So i can't detect with event connectionCreated
What do you mean "data"? For import method?
Is for import method use event "import" and loop connections for the import data.
Add these lines in "this.editor.on('connectionCreated', (connection: any) => { console.log(connection) }" like below, e.g.,
this.editor.on('connectionCreated', (connection: any) => {
let outputConnectedNode = this.editor.getNodeFromId(connection.output_id);
let inputConnectedNode = this.editor.getNodeFromId(connection.input_id);
// if required check for appropriate outputConnectedNode and inputConnectedNode
if(outputConnectedNode.class = "<check class>" || inputConnectedNode.class = "<check class>")
// add a custom class for the connection created
document.getElementsByClassName("node_out_node-"+ connection.output_id +" "+ "node_in_node-"+ connection.input_id)[0].classList.add("greenClass");
}
And then add css for the custom class
.greenClass path{
stroke: green;
}
I want to change color of path with input node type. Thank?