Hi,
I have two shapes S1 and S2 linked with one connector C.
When I cut the shape S2, the event collectionChange is trigger first for the connector C, then for S2. That's fine.
But the shape S1 is also modified : S1.outEdges['C'] => S1.outEdges[]. But I get an event for this modification.
It's necessary for me to get this event.
Can you provide me a way to catch this event?
Regards,
Laurent
Sorry there is a mistake. Replace " But I get an event for this modification." by " But I can't get an event for this modification."
I have the same question when connection change. CHanging a connection has an impact on the inEdges or OutEdges of the nodes. We have the connectionChange event when changing the connector. But we don't have an event triggered by the modification of the node.InEdges/outEdges?
So my question is both when removing a connector or changing the connection, can we have an event trigger by the modification of the nodes ?
Hi Laurent,
When we delete a connector or changing the connection, the collectionChange and connectionChange event gets triggered respectively. You will get the connector object alone in the event. To know the changes in the node inEdges and outEdges property, we need to get a node object in that event. It is possible to get a node object using getNodeObject method in that event. We have created a sample to achieve your requirement. Please refer to a code example below.
Code example:
|
let diagram: Diagram = new Diagram({ width: '100%', height: '700px', nodes: nodes, connectors: connectors, collectionChange: function collectionChange(args) { //when we delete a connector if (args.element && args.element.segments && args.type === 'Removal') { //get the sourceNode and targetNode var sourceNode = this.getNodeObject(args.element.sourceID); var targetNode = this.getNodeObject(args.element.targetID); } }, connectionChange: function connectionChange(args) { if (args.state === 'Changing') { //get a node object if (args.newValue.nodeId) { var node = this.getNodeObject(args.newValue.nodeId); } else { var node = this.getNodeObject(args.oldValue.nodeId); } } }, |
Sample: https://stackblitz.com/edit/puamzy
Regards,
Shyam G