From d666a2d7c3e55044435cfecd548caa3467b735d9 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Nov 2024 20:38:22 +0000 Subject: [Lightbox] Set 2 as minimal allowed zoom level (#6132) * [Lightbox] Set 2 as minimal allowed zoom level on iOS * Fix both Android and iOS --- .../ImageViewing/components/ImageItem/ImageItem.ios.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx') diff --git a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx index e8f36d520..a17d4fe66 100644 --- a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx +++ b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx @@ -28,7 +28,7 @@ import {ImageSource} from '../../@types' const SWIPE_CLOSE_OFFSET = 75 const SWIPE_CLOSE_VELOCITY = 1 const MAX_ORIGINAL_IMAGE_ZOOM = 2 -const MIN_DOUBLE_TAP_SCALE = 2 +const MIN_SCREEN_ZOOM = 2 type Props = { imageSrc: ImageSource @@ -56,10 +56,13 @@ const ImageItem = ({ src: imageSrc.uri, knownDimensions: imageSrc.dimensions, }) - const maxZoomScale = imageDimensions - ? (imageDimensions.width / screenSizeDelayedForJSThreadOnly.width) * - MAX_ORIGINAL_IMAGE_ZOOM - : 1 + const maxZoomScale = Math.max( + MIN_SCREEN_ZOOM, + imageDimensions + ? (imageDimensions.width / screenSizeDelayedForJSThreadOnly.width) * + MAX_ORIGINAL_IMAGE_ZOOM + : 1, + ) const animatedStyle = useAnimatedStyle(() => { return { @@ -218,7 +221,7 @@ const getZoomRectAfterDoubleTap = ( const zoom = Math.max( imageAspect / screenAspect, screenAspect / imageAspect, - MIN_DOUBLE_TAP_SCALE, + MIN_SCREEN_ZOOM, ) // Unlike in the Android version, we don't constrain the *max* zoom level here. // Instead, this is done in the ScrollView props so that it constraints pinch too. -- cgit 1.4.1