Link location when connected to a port

Hi,
I’m using portShiftingTool to move and connect ports.
When i use auto layout, sometimes the links are located to the left of the port (see left node) or to the right of the port (see right node).
How can i control the link location to be on the right (good) location ?

Especially, if the user moves a port , how can locate the link (progrematically) to the on the right location ?

Don’t use small ports that are positioned at specific spots on the node. Instead use most or all of the node, and allow the route to be computed to the nearest points by not setting fromSpot or toSpot. GoJS Links -- Northwoods Software and GoJS Link Connection Points on Nodes -- Northwoods Software.

In this case, make sure the layout does not set specific link spots, as several of the layouts do. Or use go.Spot.AllSides.

But i have to use ports.
A port in my project represents a real physical port which is connected via cable (link in gojs) to other port.
It is a monitored entity that changes its color subject to operational state (up/down).
I’m willing to write a dedicated algorithm that computes the link location according to the port location but i have no clue how to implement it.

I think you’ll need to customize the port shifting tool to reassign the moved port’s fromSpot and toSpot based on its new location relative to the center of the node. Modify PortShiftingTool.doMouseUp.

I will try but why are you suggesting to modify the doMouseUp method ?
It does not happen when i move the port.
It happens when i do auto layout.
So it is the right place to make the change ?

I think this is discussed in the topic Find the connected Link from port.