Skip to content

Commit a9d93bf

Browse files
committed
Fixes the problem when the aspect ratio is less than 1, that the selection has an incorrect resolution
1 parent 9ad0476 commit a9d93bf

File tree

2 files changed

+13
-5
lines changed
  • ts/WoltLabSuite/Core/Component/Image
  • wcfsetup/install/files/js/WoltLabSuite/Core/Component/Image

2 files changed

+13
-5
lines changed

ts/WoltLabSuite/Core/Component/Image/Cropper.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,13 @@ class MinMaxImageCropper extends ImageCropper {
372372

373373
protected centerSelection(): void {
374374
this.cropperImage!.$center("contain");
375+
this.#cropperCanvasRect = this.cropperImage!.getBoundingClientRect();
375376

376-
const { width: imageWidth } = this.cropperImage!.getBoundingClientRect();
377-
378-
this.cropperSelection!.$change(0, 0, imageWidth, 0, this.configuration.aspectRatio, true);
377+
if (this.configuration.aspectRatio >= 1.0) {
378+
this.cropperSelection!.$change(0, 0, this.#cropperCanvasRect.width, 0, this.configuration.aspectRatio, true);
379+
} else {
380+
this.cropperSelection!.$change(0, 0, 0, this.#cropperCanvasRect.height, this.configuration.aspectRatio, true);
381+
}
379382
this.cropperSelection!.$center();
380383
this.cropperSelection!.scrollIntoView({ block: "center", inline: "center" });
381384
}

wcfsetup/install/files/js/WoltLabSuite/Core/Component/Image/Cropper.js

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)