NorthwoodsSoftware / GoJS

JavaScript diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.
http://gojs.net
Other
7.8k stars 2.86k forks source link

Group's location that have priority over Node's location #160

Closed senese closed 3 years ago

senese commented 3 years ago

I am developing a GoJS Diagram based on the Leaflet example. That means that redraw and updateAllTargetBindings methods are included (on any move event). My diagram though has groups that expand/collapses their placeholders with a certain zoom level.

As I looked up on GoJS forum, when groups have Placeholders their locations are ignored in favor of nodes locations. This logic causes an odd behaviour that when the zoom in or zoom out happens, the redraw() method causes the group location binding be considered for a brief moment and then node location binding takes place.

So you can imagine that in this example the group Lat-Long is more important than the node Lat-Long, but the Placeholder is still very important because it can be dinamically resized depending on the number of children nodes.

With group location having priority, the developer doesn't have to assign any location to a node. So my propose here is to create a property that makes group's location prevail over node's location.

WalterNorthwoods commented 3 years ago

The whole purpose of a Placeholder is to position and size the Group based on the group's members. If you want the position/location of a Group to be independent of its members, don't use a Placeholder. If you want the size to depend on the members somehow, implement it yourself. https://gojs.net/latest/intro/sizedGroups.html For a completely different scenario, not using Groups: https://gojs.net/latest/samples/sharedStates.html

senese commented 3 years ago

Hello Walter, thank you for your answer.

I'm trying to adapt the code to the same way as sharedStates does. Although you see that sharedStates still need Nodes location to position it's super nodes. Even the super node being dynamically sized according to nodes location, once you get rid of the nodes location binding the diagram breaks.

I've seen some questions on the forum asking how to fix groups location when using Placeholders, so there is some people that would benefit from that feature.

I'll continue to try implement a way to do this, but if Placeholders had a second behaviour of simply being pure placeholders that holds a collection of Nodes without caring about nodes location, this will save a lot of time and code.

WalterNorthwoods commented 3 years ago

If you have a design where each Node is only (at most) a member of a single collection Part, then you can use Groups. That Shared States sample is unusual in that it implements a design where nodes can be members of multiple collection Parts.

If you are using a Group and you want the group's size and location to depend on the union of the bounds of its member Parts, then use a Placeholder. Otherwise don't use a Placeholder, and you can do anything you want with the size and location of the Group.