Detect when a port is dis/connected to a link #2703
Replies: 2 comments 2 replies
-
When adjusting the appearance of your shapes based on specific rules, it's a good practice not to include these calculated changes in the CommandManager history. Instead, recalculate them whenever the CommandManager alters the graph structure, such as during an undo or redo operation. You can implement this approach in two ways:
Personally, I prefer using highlighters to display temporary effects on elements, as it allows me to separate shape definitions from visual effects. This separation is useful when you have different views of the same graph where these effects might not be necessary. For instance, imagine an edit mode where no monitoring is displayed and a view mode with live status updates. A relevant example can be seen in our DWDM demo. |
Beta Was this translation helpful? Give feedback.
-
Introduction
Hi Roman! Is there a way I can detect if a port has been dis/connected from a link?
Currently I'm using the following 3 methods (workarounds):
link:connect
event on the paper.remove
event on the graph (since thelink:disconnected
event on the paper won't trigger if the link is removed. btw, is that a bug or a feature?)With these 3 workarounds combined I'm able to modify the size / color of the ports when a link it dis/connected to/from them. But this is not ideal at all. It feels extremely hacky and it doesn't play nice with the command manager (eg, I have two cells with their ports color set to
red
and radius4
, I connect them with a link, which triggers some code that sets the port color togreen
and radius6
, then I undo the operation with the command manager).I could keep hacking and subscribe to the command manager push / pop events and trigger my custom from there, but that just feels like fixing the wrong problem. Is there a way I can manage port colors / size more easily?
Steps to reproduce
No response
Restrictions & Constraints
No response
Does your question relate to JointJS or JointJS+. Select both if applicable.
JointJS
Beta Was this translation helpful? Give feedback.
All reactions