Link behavior that I want avoid

In video you can see what is happening with link route when some additional shapes are shown on elements. I am using Avoidable routing there but all I want that link preserve their route until element is not moved across the diagram. What I can do to accomplish this?

Just to be clear – do you want to avoid the behavior that appears to be shown in the video where the routes of the links are frequently changing?

Because that’s pretty wild. Do you have any mouse event handlers or timers that are changing the size or visibility of any objects?

Yes I want to avoid exactly that.

I have a mouse event handlers that cause some GraphObjects show accordingly. That probably changes size of the object and I want that link calculation ignore everything except locationObject size because that is always fixed size. Something similar we have now in GoJS 2 in guided dragging tool extension.

Is there only one port for each Node? If so, I am guessing that you have not specified the visible rectangle to be the port, rather than the whole Node which holds some objects that are sometimes or often not visible.

You can do that by setting { portId: "" } on that rectangular element.

No. I am having 4 ports (vertical’s and horizontal’s in and out). My node template is quite complex with many graph objects which change their visibility according to node state, mouse cursor distance and so on.

And those links are connecting with specific ports? If so, that implies as you are changing the visibility of elements in a node, you are changing the size and/or position of those ports. I suggest that you change your node design so that the ports do not move relative to the node.

Hm okay. I will check but as I remember position of the ports is fixed, otherwise lines will start or finish where I don’t want to. Only what changes there is obviously node size but let me check are ports really static or they move even a little.

Addition to my previous answer:
I did small test and test showed me that port is moved by 0.5 by x coordinate which of course is unnoticeable by eye :). Okay I will try to fix that small movement of port and let you know about results.

I discovered what caused this port small movement. It was strokeWidth on selection. I commented that binding and now port does not changes its document position at all but still I have change in link shape. Then I returned back strokeWidth change which changes port to be moved a little, but turned off that small tip so node width is not changed at all and link stands still while port is shifted by 0.5.

This tells me, no matter port is static or not link will change its shape/route if node size is changed making additional graph object visible. I need a way to tell link to take into computation only locationObject size and to ignore node size.

Well, if you are using AvoidsNodes routing, of course the route has to be different to account for the larger/smaller node.

Yeah but strange thing is that link becomes closer to bigger node than to smaller. Okay I will try with Orthogonal only to see. But I still think it would be nice to have some configuration option for AvoidsNodes to take into account only locationObject.

You could try setting Node | GoJS API to a suitably sized negative margin.

1 Like