Fix bug in lightbox rendering (#133)
This commit is contained in:
@@ -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) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user