diff options
author | dan <dan.abramov@gmail.com> | 2024-11-06 20:38:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 20:38:22 +0000 |
commit | d666a2d7c3e55044435cfecd548caa3467b735d9 (patch) | |
tree | 421dc370a7a3881b8492c63151efd4ca2131b387 /src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx | |
parent | 27bbf8b67a578b719754322551ba0bc79666cb9e (diff) | |
download | voidsky-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.android.tsx')
-rw-r--r-- | src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx | 16 |
1 files changed, 10 insertions, 6 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 ea77ec273..ed6020000 100644 --- a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx +++ b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx @@ -26,7 +26,7 @@ import { TransformMatrix, } from '../../transforms' -const MIN_DOUBLE_TAP_SCALE = 2 +const MIN_SCREEN_ZOOM = 2 const MAX_ORIGINAL_IMAGE_ZOOM = 2 const initialTransform = createTransform() @@ -166,8 +166,10 @@ const ImageItem = ({ // Don't let the picture zoom in so close that it gets blurry. // Also, like in stock Android apps, don't let the user zoom out further than 1:1. const [, , committedScale] = readTransform(committedTransform.value) - const maxCommittedScale = - (imageDimensions.width / screenSize.width) * MAX_ORIGINAL_IMAGE_ZOOM + const maxCommittedScale = Math.max( + MIN_SCREEN_ZOOM, + (imageDimensions.width / screenSize.width) * MAX_ORIGINAL_IMAGE_ZOOM, + ) const minPinchScale = 1 / committedScale const maxPinchScale = maxCommittedScale / committedScale const nextPinchScale = Math.min( @@ -277,11 +279,13 @@ const ImageItem = ({ const candidateScale = Math.max( imageAspect / screenAspect, screenAspect / imageAspect, - MIN_DOUBLE_TAP_SCALE, + MIN_SCREEN_ZOOM, ) // But don't zoom in so close that the picture gets blurry. - const maxScale = - (imageDimensions.width / screenSize.width) * MAX_ORIGINAL_IMAGE_ZOOM + const maxScale = Math.max( + MIN_SCREEN_ZOOM, + (imageDimensions.width / screenSize.width) * MAX_ORIGINAL_IMAGE_ZOOM, + ) const scale = Math.min(candidateScale, maxScale) // Calculate where we would be if the user pinched into the double tapped point. |