From 112504bac76f6ae61928430bc6e00180df451856 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 8 Nov 2024 03:36:35 +0000 Subject: [PATCH] Fix tall image final state The initial animation frame is still off on both platforms. --- .../components/ImageItem/ImageItem.android.tsx | 7 +++++-- src/view/com/lightbox/ImageViewing/index.tsx | 12 ++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx index 1a158fd1c3..8413388e4e 100644 --- a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx +++ b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx @@ -325,10 +325,13 @@ const ImageItem = ({ {translateY: translateY}, {scale}, ] + const screenSize = measureSafeArea() return { - width: '100%', - aspectRatio: imageAspect, transform: scaleAndMoveTransform.concat(manipulationTransform), + width: screenSize.width, + maxHeight: screenSize.height, + aspectRatio: imageAspect, + alignSelf: 'center', } }) diff --git a/src/view/com/lightbox/ImageViewing/index.tsx b/src/view/com/lightbox/ImageViewing/index.tsx index 33302534cb..57d6838143 100644 --- a/src/view/com/lightbox/ImageViewing/index.tsx +++ b/src/view/com/lightbox/ImageViewing/index.tsx @@ -640,8 +640,16 @@ function interpolateTransform( uncroppedInitialWidth = thumbnailDims.width uncroppedInitialHeight = thumbnailDims.width / imageAspect } - const finalWidth = safeArea.width - const finalHeight = safeArea.width / imageAspect + const safeAreaAspect = safeArea.width / safeArea.height + let finalWidth + let finalHeight + if (safeAreaAspect > imageAspect) { + finalWidth = safeArea.height * imageAspect + finalHeight = safeArea.height + } else { + finalWidth = safeArea.width + finalHeight = safeArea.width / imageAspect + } const initialScale = Math.min( uncroppedInitialWidth / finalWidth, uncroppedInitialHeight / finalHeight,