Skip to content

Commit

Permalink
Fixes the problem when the aspect ratio is less than 1, that the sele…
Browse files Browse the repository at this point in the history
…ction has an incorrect resolution
  • Loading branch information
Cyperghost committed Dec 6, 2024
1 parent 9ad0476 commit a9d93bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 6 additions & 3 deletions ts/WoltLabSuite/Core/Component/Image/Cropper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,13 @@ class MinMaxImageCropper extends ImageCropper {

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

const { width: imageWidth } = this.cropperImage!.getBoundingClientRect();

this.cropperSelection!.$change(0, 0, imageWidth, 0, this.configuration.aspectRatio, true);
if (this.configuration.aspectRatio >= 1.0) {
this.cropperSelection!.$change(0, 0, this.#cropperCanvasRect.width, 0, this.configuration.aspectRatio, true);
} else {
this.cropperSelection!.$change(0, 0, 0, this.#cropperCanvasRect.height, this.configuration.aspectRatio, true);
}
this.cropperSelection!.$center();
this.cropperSelection!.scrollIntoView({ block: "center", inline: "center" });
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a9d93bf

Please sign in to comment.