From 4a2d461338ab85a81b58052c4eab7e689ef5ad1b Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Wed, 18 Dec 2024 09:01:47 +0100 Subject: [PATCH] Remove round Limit to max width and height --- ts/WoltLabSuite/Core/Component/Image/Cropper.ts | 12 ++++++------ .../js/WoltLabSuite/Core/Component/Image/Cropper.js | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ts/WoltLabSuite/Core/Component/Image/Cropper.ts b/ts/WoltLabSuite/Core/Component/Image/Cropper.ts index 0df7481033..8212edbefe 100644 --- a/ts/WoltLabSuite/Core/Component/Image/Cropper.ts +++ b/ts/WoltLabSuite/Core/Component/Image/Cropper.ts @@ -222,10 +222,10 @@ abstract class ImageCropper { const maxHeight = maxWidth / this.configuration.aspectRatio; if ( - Math.round(selection.width) < minWidth || - Math.round(selection.height) < minHeight || - Math.round(selection.width) > maxWidth || - Math.round(selection.height) > maxHeight + selection.width < minWidth || + selection.height < minHeight || + selection.width > maxWidth || + selection.height > maxHeight ) { event.preventDefault(); } @@ -260,8 +260,8 @@ abstract class ImageCropper { this.cropperSelection!.$change( 0, 0, - this.maxSize.width * selectionRatio, - this.maxSize.height * selectionRatio, + Math.min(this.cropperCanvasRect.width, this.maxSize.width * selectionRatio), + Math.min(this.cropperCanvasRect.height, this.maxSize.height * selectionRatio), this.configuration.aspectRatio, true, ); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Image/Cropper.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Image/Cropper.js index 046b13b6cd..06c2cf3796 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Image/Cropper.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Image/Cropper.js @@ -165,10 +165,10 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Image/Resizer", "WoltL const maxWidth = this.cropperCanvasRect.width; const minHeight = minWidth / this.configuration.aspectRatio; const maxHeight = maxWidth / this.configuration.aspectRatio; - if (Math.round(selection.width) < minWidth || - Math.round(selection.height) < minHeight || - Math.round(selection.width) > maxWidth || - Math.round(selection.height) > maxHeight) { + if (selection.width < minWidth || + selection.height < minHeight || + selection.width > maxWidth || + selection.height > maxHeight) { event.preventDefault(); } }); @@ -188,7 +188,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Image/Resizer", "WoltL this.cropperImage.$center("contain"); this.cropperCanvasRect = this.cropperImage.getBoundingClientRect(); const selectionRatio = Math.min(this.cropperCanvasRect.width / this.maxSize.width, this.cropperCanvasRect.height / this.maxSize.height); - this.cropperSelection.$change(0, 0, this.maxSize.width * selectionRatio, this.maxSize.height * selectionRatio, this.configuration.aspectRatio, true); + this.cropperSelection.$change(0, 0, Math.min(this.cropperCanvasRect.width, this.maxSize.width * selectionRatio), Math.min(this.cropperCanvasRect.height, this.maxSize.height * selectionRatio), this.configuration.aspectRatio, true); this.cropperSelection.$center(); this.cropperSelection.scrollIntoView({ block: "center", inline: "center" }); } -- 2.20.1