Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Lightbox] Set 2 as minimal allowed zoom level (#6132)

* [Lightbox] Set 2 as minimal allowed zoom level on iOS

* Fix both Android and iOS

authored by

dan and committed by
GitHub
d666a2d7 27bbf8b6

+19 -12
+10 -6
src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.android.tsx
··· 26 26 TransformMatrix, 27 27 } from '../../transforms' 28 28 29 - const MIN_DOUBLE_TAP_SCALE = 2 29 + const MIN_SCREEN_ZOOM = 2 30 30 const MAX_ORIGINAL_IMAGE_ZOOM = 2 31 31 32 32 const initialTransform = createTransform() ··· 166 166 // Don't let the picture zoom in so close that it gets blurry. 167 167 // Also, like in stock Android apps, don't let the user zoom out further than 1:1. 168 168 const [, , committedScale] = readTransform(committedTransform.value) 169 - const maxCommittedScale = 170 - (imageDimensions.width / screenSize.width) * MAX_ORIGINAL_IMAGE_ZOOM 169 + const maxCommittedScale = Math.max( 170 + MIN_SCREEN_ZOOM, 171 + (imageDimensions.width / screenSize.width) * MAX_ORIGINAL_IMAGE_ZOOM, 172 + ) 171 173 const minPinchScale = 1 / committedScale 172 174 const maxPinchScale = maxCommittedScale / committedScale 173 175 const nextPinchScale = Math.min( ··· 277 279 const candidateScale = Math.max( 278 280 imageAspect / screenAspect, 279 281 screenAspect / imageAspect, 280 - MIN_DOUBLE_TAP_SCALE, 282 + MIN_SCREEN_ZOOM, 281 283 ) 282 284 // But don't zoom in so close that the picture gets blurry. 283 - const maxScale = 284 - (imageDimensions.width / screenSize.width) * MAX_ORIGINAL_IMAGE_ZOOM 285 + const maxScale = Math.max( 286 + MIN_SCREEN_ZOOM, 287 + (imageDimensions.width / screenSize.width) * MAX_ORIGINAL_IMAGE_ZOOM, 288 + ) 285 289 const scale = Math.min(candidateScale, maxScale) 286 290 287 291 // Calculate where we would be if the user pinched into the double tapped point.
+9 -6
src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx
··· 28 28 const SWIPE_CLOSE_OFFSET = 75 29 29 const SWIPE_CLOSE_VELOCITY = 1 30 30 const MAX_ORIGINAL_IMAGE_ZOOM = 2 31 - const MIN_DOUBLE_TAP_SCALE = 2 31 + const MIN_SCREEN_ZOOM = 2 32 32 33 33 type Props = { 34 34 imageSrc: ImageSource ··· 56 56 src: imageSrc.uri, 57 57 knownDimensions: imageSrc.dimensions, 58 58 }) 59 - const maxZoomScale = imageDimensions 60 - ? (imageDimensions.width / screenSizeDelayedForJSThreadOnly.width) * 61 - MAX_ORIGINAL_IMAGE_ZOOM 62 - : 1 59 + const maxZoomScale = Math.max( 60 + MIN_SCREEN_ZOOM, 61 + imageDimensions 62 + ? (imageDimensions.width / screenSizeDelayedForJSThreadOnly.width) * 63 + MAX_ORIGINAL_IMAGE_ZOOM 64 + : 1, 65 + ) 63 66 64 67 const animatedStyle = useAnimatedStyle(() => { 65 68 return { ··· 218 221 const zoom = Math.max( 219 222 imageAspect / screenAspect, 220 223 screenAspect / imageAspect, 221 - MIN_DOUBLE_TAP_SCALE, 224 + MIN_SCREEN_ZOOM, 222 225 ) 223 226 // Unlike in the Android version, we don't constrain the *max* zoom level here. 224 227 // Instead, this is done in the ScrollView props so that it constraints pinch too.