One way I found to achieve this is by overwriting the ResizingTool computeResize method
computeResize(
newPoint: go.Point,
spot: go.Spot,
min: go.Size,
max: go.Size,
cell: go.Size,
reshape: boolean // ignore this ?
): go.Rect {
// Get the Node data
const blockData = this.adornedObject.part.data as Block;
// Preserve aspect ratio ?
const lockAspectRatio = !getAspectRationByCategory(blockData.category);
return super.computeResize(newPoint, spot, min, max, cell, lockAspectRatio);
}
However I am not sure if this is the best way to achieve this. I know that the computeResize
returns a reshape
boolean. But I am not sure how can I set it and where ? (Since I don’t think it’s always true)
For some group (template), I want to lock the aspect ratio. Is it possible to achieve this just by turning a boolean off/on in the Template ? Is there any other way without overwiting the ResizingTool.