From 806449b5ac6840d35033dc427d3182f0aa8b9a80 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 17 Nov 2023 16:52:53 +0100 Subject: [PATCH] Fix setting scaledImage width and height --- .../AttachmentCarousel/Pager/AttachmentCarouselPage.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js b/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js index 87720e1c43a7..f529522c2854 100644 --- a/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js +++ b/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js @@ -97,7 +97,14 @@ function AttachmentCarouselPage({source, isAuthTokenRequired, isActive: initialI const imageHeight = (evt.nativeEvent?.height || 0) / PixelRatio.get(); const {imageScaleX, imageScaleY} = getCanvasFitScale({canvasWidth, canvasHeight, imageWidth, imageHeight}); + let scaledImageWidth = dimensions?.scaledImageWidth; + let scaledImageHeight = dimensions?.scaledImageHeight; + if (!scaledImageHeight && !scaledImageWidth) { + const minImageScale = Math.min(imageScaleX, imageScaleY); + scaledImageWidth = imageWidth * minImageScale; + scaledImageHeight = imageHeight * minImageScale; + } // Don't update the dimensions if they are already set if ( dimensions?.imageWidth !== imageWidth || @@ -111,6 +118,8 @@ function AttachmentCarouselPage({source, isAuthTokenRequired, isActive: initialI imageHeight, imageScaleX, imageScaleY, + scaledImageWidth, + scaledImageHeight, }); }