Fix bug in lightbox rendering (#133)

This commit is contained in:
Paul Frazee
2023-02-01 13:20:43 -06:00
committed by GitHub
parent 1e5330931d
commit 865deb930b
+7 -2
View File
@@ -86,12 +86,18 @@ function ImageViewing({
[toggleBarsVisible], [toggleBarsVisible],
) )
const onLayout = useCallback(() => {
if (imageIndex) {
imageList.current?.scrollToIndex({index: imageIndex, animated: false})
}
}, [imageList, imageIndex])
if (!visible) { if (!visible) {
return null return null
} }
return ( return (
<View style={styles.screen}> <View style={styles.screen} onLayout={onLayout}>
<Modal /> <Modal />
<View style={[styles.container, {opacity, backgroundColor}]}> <View style={[styles.container, {opacity, backgroundColor}]}>
<Animated.View style={[styles.header, {transform: headerTransform}]}> <Animated.View style={[styles.header, {transform: headerTransform}]}>
@@ -110,7 +116,6 @@ function ImageViewing({
pagingEnabled pagingEnabled
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
initialScrollIndex={imageIndex}
getItem={(_, index) => images[index]} getItem={(_, index) => images[index]}
getItemCount={() => images.length} getItemCount={() => images.length}
getItemLayout={(_, index) => ({ getItemLayout={(_, index) => ({