fix: preserve aspect ratio

This commit is contained in:
Konstantinos Kaloutas
2023-06-22 12:53:14 +03:00
committed by Gabriel Horner
parent 31a0ed40bc
commit 08f70c979e
2 changed files with 6 additions and 5 deletions

View File

@@ -69,17 +69,18 @@ export class CreatingState<
if (!this.creatingShape) throw Error('Expected a creating shape.')
const { initialBounds } = this
const { currentPoint, originPoint, shiftKey } = this.app.inputs
const isAspectRatioLocked = shiftKey ||
this.creatingShape.props.isAspectRatioLocked ||
!this.creatingShape.canChangeAspectRatio
let bounds = BoundsUtils.getTransformedBoundingBox(
initialBounds,
TLResizeCorner.BottomRight,
Vec.sub(currentPoint, originPoint),
0,
shiftKey ||
this.creatingShape.props.isAspectRatioLocked ||
!this.creatingShape.canChangeAspectRatio
isAspectRatioLocked
)
if (this.app.settings.snapToGrid) {
if (this.app.settings.snapToGrid && !isAspectRatioLocked) {
bounds = BoundsUtils.snapBoundsToGrid(bounds, GRID_SIZE)
}

View File

@@ -218,7 +218,7 @@ export class ResizingState<
// relativeBounds = BoundsUtils.centerBounds(relativeBounds, center)
// }
if (this.app.settings.snapToGrid) {
if (this.app.settings.snapToGrid && !isAspectRatioLocked) {
relativeBounds = BoundsUtils.snapBoundsToGrid(relativeBounds, GRID_SIZE)
}