Prevent OOB scroll on iOS when zoomed in

This commit is contained in:
Dan Abramov
2024-11-01 03:20:00 +00:00
parent aeda009b2f
commit de1a6fe14d
@@ -7,7 +7,7 @@
*/ */
import React, {useState} from 'react' import React, {useState} from 'react'
import {ActivityIndicator, Dimensions, StyleSheet, View} from 'react-native' import {ActivityIndicator, Dimensions, StyleSheet} from 'react-native'
import { import {
Gesture, Gesture,
GestureDetector, GestureDetector,
@@ -121,44 +121,34 @@ const ImageItem = ({
<Animated.ScrollView <Animated.ScrollView
// @ts-ignore Something's up with the types here // @ts-ignore Something's up with the types here
ref={scrollViewRef} ref={scrollViewRef}
style={styles.listItem}
pinchGestureEnabled pinchGestureEnabled
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
maximumZoomScale={maxZoomScale} maximumZoomScale={maxZoomScale}
onScroll={scrollHandler} onScroll={scrollHandler}
bounces={scaled}> bounces={scaled}
<View style={styles.imageScrollContainer}> centerContent>
<ActivityIndicator size="small" color="#FFF" style={styles.loading} /> <ActivityIndicator size="small" color="#FFF" style={styles.loading} />
<Image <Image
contentFit="contain" contentFit="contain"
source={{uri: imageSrc.uri}} source={{uri: imageSrc.uri}}
placeholderContentFit="contain" placeholderContentFit="contain"
placeholder={{uri: imageSrc.thumbUri}} placeholder={{uri: imageSrc.thumbUri}}
style={styles.image} style={{
accessibilityLabel={imageSrc.alt} width: SCREEN.width,
accessibilityHint="" height: imageAspect ? SCREEN.width / imageAspect : undefined,
enableLiveTextInteraction={showControls && !scaled} }}
accessibilityIgnoresInvertColors accessibilityLabel={imageSrc.alt}
/> accessibilityHint=""
</View> enableLiveTextInteraction={showControls && !scaled}
accessibilityIgnoresInvertColors
/>
</Animated.ScrollView> </Animated.ScrollView>
</GestureDetector> </GestureDetector>
) )
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
imageScrollContainer: {
height: SCREEN.height,
},
listItem: {
width: SCREEN.width,
height: SCREEN.height,
},
image: {
width: SCREEN.width,
height: SCREEN.height,
},
loading: { loading: {
position: 'absolute', position: 'absolute',
top: 0, top: 0,