Trying to achieve groups where the padding amount around members increase depending on how many members the group has. So in essence making Placeholder.padding
bound to ...memberParts.count
.
It seems making a Binding that depends on .memberParts.count
does not cut it. It works when interactively working with the diagram, but when loading an existing diagram using .fromJson()
, the counts are always zero. It is not until you poke the group that the padding gets calculated correctly.
I have already gotten around this using tips from other posts in this forum, with this code, which gives me a data property that I can bind to instead, which works fine:
// Since memberParts.count do not update on load, we maintain our own counter...
const updateGroupCount = g => {
g.diagram.model.setDataProperty( g.data, 'count', g.memberParts.count )
}
diagram.groupTemplate =
goObject( go.Group, "Horizontal",
{
ungroupable: true, // User can ungroup nodes from this
avoidable: false, // Links can route across (otherwise we can't get in!)
computesBoundsAfterDrag: true,
mouseDrop( e, grp ) {
const ok = ( grp !== null
? grp.addMembers( grp.diagram.selection, true )
: e.diagram.commandHandler.addTopLevelParts( e.diagram.selection, true ) )
if( !ok ) e.diagram.currentTool.doCancel()
},
handlesDragDropForMembers: true, // Don't need to define handlers on member Nodes and Links
memberAdded: updateGroupCount,
memberRemoved: updateGroupCount
},
…but it seems a bit unnecessary to have to do this. Is counts not updating on model load the expected behaviour, or is this maybe a bug?