Dragging tool "squish" behavior

I don’t want graph objects in my gojs diagram to be able to be dragged past a certain edge of my graph. To achieve that, I’ve implemented some limits in the node’s dragComputation function.

This works nicely, except now, when I multi select and drag, the nodes just kind of squish together and stack up on the edge, when really I want them to keep their relative spacing.

It seems like some combination of the code I have and computeMove is the right thing to do, where computeMove basically calls my dragComputation function for all the parts, and, if any of the proposed locations is different than the returned locations, just don’t allow any parts to move.

Is there a simpler way than this, ands there anything to watch out for when reimplementing computeMove?

mc.

Yes, the default behavior seemed to be most preferred for situations when trying to avoid dragging into certain areas. This is demonstrated by Drag Unoccupied. But what you suggest is certainly a reasonable requirement, especially when the goal is keeping everything within a box rather than trying to avoid overlaps.

Actually, I think the better solution for you is to override DraggingTool.moveParts. I don’t have time right now to do this for you, but maybe I will later this weekend.

Here you go:
https://gojs.net/extras/LimitedDragging.html

The complete implementation is right there on the page: a LimitedDraggingTool class, whose LimitedDraggingTool.limits property you set to a Rect defining the limits for where anything can be dragged by the user.

I also added a simple Part showing the limits bounds as a red rectangle.