I'm having some issues trying to get the objects to resize according to the grid size.
Here's my fiddle: http://jsfiddle.net/csh6c6fw/1/
this is the code that I'm applying:
canvas.on('object:scaling', (options) => {
var newWidth = (Math.round(options.target.getWidth() / grid)) * grid;
var newHeight = (Math.round(options.target.getHeight() / grid)) * grid;
if (options.target.getWidth() !== newWidth) {
options.target.set({ width: newWidth, height: newHeight });
}
});
Expected Result
It's supposed to snap to the grids like the movement.
This is an update to the accepted answer.
target.getWidth()
andtarget.getHeight()
don't seem to work anymore, so I updated the fiddle from the accepted answer to replace them withtarget.width * target.scaleX
andtarget.height * target.scaleY
.Here is the updated fiddle
Might seem pretty complicated but, the following will get the job done :
Here is a working example :