I modified the algorithm a bit like this.
const temp = new go.Point();
const hideLinks = [];
if (n.actualBounds.right < vb.x - MarginWidth) {
n.location = new go.Point(n.location.x + DocWidth, n.location.y);
n.findLinksConnected().each(function(l) {
l.opacity = 0.0;
hideLinks.push(l.data.key);
});
} else {
n.findLinksOutOf().each(function(l) {
if (hideLinks.indexOf(l.data.key) === -1) {
if (vb.containsPoint(l.fromPort.getDocumentPoint(go.Spot.Right, temp)))
l.opacity = 1.0;
else if (vb.containsPoint(l.toPort.getDocumentPoint(go.Spot.Left, temp)))
l.opacity = 1.0;
}
});
}
} else if (vb.x < ob.x) {
// scrolling leftwards
if (n.actualBounds.left > vb.right + MarginWidth) {
n.location = new go.Point(n.location.x - DocWidth, n.location.y);
n.findLinksConnected().each(function(l) {
l.opacity = 0.0;
hideLinks.push(l.data.key);
});
} else {
n.findLinksOutOf().each(function(l) {
if (hideLinks.indexOf(l.data.key) === -1) {
if (vb.containsPoint(l.fromPort.getDocumentPoint(go.Spot.Right, temp)))
l.opacity = 1.0;
else if (vb.containsPoint(l.toPort.getDocumentPoint(go.Spot.Left, temp)))
l.opacity = 1.0;
}
});
}
}
And yes, thanks for the tip of pickable.