When a group is expanded, the group (X,Y) location is adjusted to its members location…as far is know.
Is it possible to maintain the group (X,Y) location, so that the group will not “leave” its original collapsed (X,Y) location ?
I do not understand the behavior that you want.
But the answer is to limit what the user can do with the DraggingTool by setting https://gojs.net/latest/api/symbols/Part.html#dragComputation. For example, look at the
stayInGroup function given in https://gojs.net/latest/api/symbols/DraggingTool.html, although that might not be exactly what you want. And you might want to also set this behavior on your Groups.
Note also that if a Group does not have a Placeholder, the group’s location is not constrained by its members’ locations. https://gojs.net/latest/intro/sizedGroups.html
I did some work around :
When i call SubGraphExpandHandler, i iterate all member part and “Move” them “near” the group (X,Y).
I only suspect that the SubGraphExpandHandler handler is called AFTER the group was expanded, so the group (X,Y) is the new expanded group(X,Y) and not before it was expanded.
Am i right ?
No, in general collapsing or expanding a group does not move its members. But it also depends on the Group.layout, which might move the nodes on an expand, and on the containing layout (maybe the Diagram.layout) which might move the group on either collapse or expand due to the change in the size of the group.
When i call SubGraphExpandHandler, i iterate all member parts and i find the node with the minimum distance to group(X,Y).
Then i iterate all parts again and i part.move(distance.x, distance.y);
The group DOES move but only a small distance, since all its members are close to its (X,Y).
Do you have a Group.layout?
Do you account for the positioning of the Placeholder within the Group and any Placeholder.padding? You could reduce the effects of the design of the group by using its Group.location rather than Group.position.
I don’t have Group.layout and i do not use PlaceHolder.padding.
I will try to use location rather than position.