I am using the Placeholder for calculating computeMaxSize and computeMinSize of the resizing tool so as to restrict the shrinking of the groups.
This is the code for the groupTemplateMap.
myDiagram.groupTemplateMap.add("siteType",
goObj(go.Group, "Spot",new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify), {
layout: goObj(PoolLayout, {
angle: 90,
isOngoing: false
})
}, {
selectionAdornmentTemplate: // adornment when a group is selected
goObj(go.Adornment, "Auto",
goObj(go.Shape, "Rectangle", {
fill: null,
stroke: "dodgerblue",
strokeWidth: 3
}),
goObj(go.Placeholder)
),
toSpot: go.Spot.AllSides, // links coming into groups at any side
toEndSegmentLength: 30,
fromEndSegmentLength: 30,
resizable: true,
computesBoundsAfterDrag: true, // needed to prevent recomputing Group.placeholder bounds too soon
computesBoundsIncludingLinks: false, // to reduce occurrences of links going briefly outside the lane
handlesDragDropForMembers: true, // don't need to define handlers on member Nodes and Links
},
goObj(go.Panel, "Auto",
goObj(go.Shape, "Rectangle", {
name: "OBJSHAPE",
parameter1: 14,
fill: "transparent",
minSize: new go.Size(100, 100)
},
new go.Binding("desiredSize", "ds")),
goObj(go.Placeholder, {
padding: 30
})
),
goObj(go.TextBlock, {
name: "GROUPTEXT",
alignment: go.Spot.TopLeft,
alignmentFocus: new go.Spot(0, 0, 4, 4),
font: "Bold 20pt Sans-Serif"
},
new go.Binding("text", "lol"))
));
myDiagram.groupTemplateMap.add("serviceGroup",
goObj(go.Group, "Spot",new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify), {
dragComputation: stayInGroup
}, {
layout: goObj(go.LayeredDigraphLayout, {
angle: 90,
isOngoing: false
})
}, {
selectionAdornmentTemplate: // adornment when a group is selected
goObj(go.Adornment, "Auto",
goObj(go.Shape, "Rectangle", {
fill: null,
stroke: "dodgerblue",
strokeWidth: 3
}),
goObj(go.Placeholder)
),
toSpot: go.Spot.AllSides, // links coming into groups at any side
toEndSegmentLength: 30,
fromEndSegmentLength: 30,
resizable: true,
computesBoundsAfterDrag: true, // needed to prevent recomputing Group.placeholder bounds too soon
computesBoundsIncludingLinks: false, // to reduce occurrences of links going briefly outside the lane
handlesDragDropForMembers: true, // don't need to define handlers on member Nodes and Links
},
goObj(go.Panel, "Auto",
goObj(go.Shape, "Rectangle", {
name: "OBJSHAPE",
parameter1: 14,
fill: "transparent",
minSize: new go.Size(100, 100)
},
new go.Binding("desiredSize", "ds")),
goObj(go.Placeholder, {
padding: 30
})
),
goObj(go.TextBlock, {
name: "GROUPTEXT",
alignment: go.Spot.TopLeft,
alignmentFocus: new go.Spot(0, 0, 4, 4),
font: "Bold 20pt Sans-Serif"
},
new go.Binding("text", "lol"))
));
I cannot understand why the external group is moving when I move the internal groups after I resize the external group. Please go through the below screenshots for more clarity.
This is the initial layout of the diagram.
This is after I resize the external group. Please note the below gap between the external group and internal groups.
Now when I move the right internal group to the top. The external group also moves a bit up automatically. You can note the difference in the bottom gap between the left internal group and the external group before and after I move the right group.
Similarly, when I resize the right group, the external group also moves to the right.
I am seeing the same behavior in the internal groups too, when I move the picture nodes after resizing the (internal) groups.
Why is this happening? How to fix this?
P.S. : This happens only after I resize the groups. When I move the nodes/groups without resizing their containingGroups, all works well.