I would like to ask for some help please. In my app the rectangles need to stick to a grid. I found a solution to follow the grid when they are dragged, but in case of resize I'm at my wit's end. It takes 5 steps to reach one grid cell size with this code:
this.selectedElement.on('transform', () => {
let stepW = (this.blockSizeW / (this.stage.width() / 2));
let stepH = (this.blockSizeH / (this.stage.height() / 2));
this.selectedElement.scale({
x: Math.round(this.selectedElement.scaleX() / stepW) * stepW,
y: Math.round(this.selectedElement.scaleY() / stepH) * stepH,
});
});
Transformed rect:
Moreover the rect has strange behaviour. Scale only works right and bottom directions, when I try dragging the left or top anchors, the whole rectangle moves slowly instead of scaling. Any idea will be appreciated!
I use angular 10
, Konva 7.1.0