Skip to content

Commit e34ed19

Browse files
feat(ui): respect aspect ratio when resizing bbox on canvas
1 parent 569533e commit e34ed19

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

invokeai/frontend/web/src/features/controlLayers/konva/CanvasTool/CanvasBboxToolModule.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ export class CanvasBboxToolModule extends CanvasModuleBase {
344344
let width = roundToMultipleMin(this.konva.proxyRect.width() * this.konva.proxyRect.scaleX(), gridSize);
345345
let height = roundToMultipleMin(this.konva.proxyRect.height() * this.konva.proxyRect.scaleY(), gridSize);
346346

347-
// If shift is held and we are resizing from a corner, retain aspect ratio - needs special handling. We skip this
348-
// if alt/opt is held - this requires math too big for my brain.
349-
if (shift && CORNER_ANCHORS.includes(anchor) && !alt) {
347+
// If ratio is locked OR shift is held and we are resizing from a corner, retain aspect ratio - needs special
348+
// handling. We skip this if alt/opt is held - this requires math too big for my brain.
349+
if ((this.manager.stateApi.getBbox().aspectRatio.isLocked || (shift && CORNER_ANCHORS.includes(anchor))) && !alt) {
350350
// Fit the bbox to the last aspect ratio
351351
let fittedWidth = Math.sqrt(width * height * this.$aspectRatioBuffer.get());
352352
let fittedHeight = fittedWidth / this.$aspectRatioBuffer.get();

0 commit comments

Comments
 (0)