Skip to content

Commit

Permalink
Fix setting scaledImage width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Nov 17, 2023
1 parent c661aa9 commit 806449b
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -111,6 +118,8 @@ function AttachmentCarouselPage({source, isAuthTokenRequired, isActive: initialI
imageHeight,
imageScaleX,
imageScaleY,
scaledImageWidth,
scaledImageHeight,
});
}

Expand Down

0 comments on commit 806449b

Please sign in to comment.