about summary refs log tree commit diff
path: root/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-11-06 20:38:22 +0000
committerGitHub <noreply@github.com>2024-11-06 20:38:22 +0000
commitd666a2d7c3e55044435cfecd548caa3467b735d9 (patch)
tree421dc370a7a3881b8492c63151efd4ca2131b387 /src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx
parent27bbf8b67a578b719754322551ba0bc79666cb9e (diff)
downloadvoidsky-d666a2d7c3e55044435cfecd548caa3467b735d9.tar.zst
[Lightbox] Set 2 as minimal allowed zoom level (#6132)
* [Lightbox] Set 2 as minimal allowed zoom level on iOS

* Fix both Android and iOS
Diffstat (limited to 'src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx')
-rw-r--r--src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx15
1 files changed, 9 insertions, 6 deletions
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.