Răsfoiți Sursa

fix: preserve aspect ratio

Konstantinos Kaloutas 2 ani în urmă
părinte
comite
08f70c979e

+ 5 - 4
tldraw/packages/core/src/lib/tools/TLBoxTool/states/CreatingState.tsx

@@ -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)
     }
 

+ 1 - 1
tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts

@@ -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)
       }