What we want to achieve is drop groups on existing group. On groupTemplate mouse drop event when we handle group creating the position of new group just gets reset to (0,0). Below is the code
const newNode = e.diagram.selection.first();
e.diagram.commandHandler.deleteSelection();
const transformNode = createNewZoneNode(newNode.data);
// createNewZoneNode we added logic of creating uniqueKeyGenerator
diagram.model.addNodeData({ ...transformNode });
diagram.commitTransaction('new group');
Below is code for group template
$(
go.Group,
{
layerName: 'Background',
resizable: false,
selectable: false,
resizeObjectName: 'SHAPE',
},
new go.Binding('position', 'pos', go.Point.parse).makeTwoWay(go.Point.stringify),
$(go.Picture, new go.Binding('source', 'src'), {
width: 210,
height: 500,
margin: 2,
position: new go.Point(0, 0),
imageStretch: go.GraphObject.Fill,
}),
);
And below is the code for group template that is dragged from Palette and dropped on above group template.
$(
go.Group,
{
layerName: 'Deck',
resizable: true,
selectable: true,
resizeObjectName: 'SHAPE',
},
new go.Binding('position', 'pos', go.Point.parse).makeTwoWay(go.Point.stringify),
$(
go.Shape,
{
name: 'SHAPE',
fill: 'transparent',
strokeWidth: 1.5,
stroke: '#1646A8',
},
new go.Binding('opacity', 'isHighlighted', (h) => (h ? 0.4 : 1)).ofObject(),
new go.Binding('figure'),
new go.Binding('geometry', 'geo', (v) => go.Geometry.parse(v, false)),
),
)