Scroll waits for pinch
This commit is contained in:
@@ -156,6 +156,7 @@ const ImageItem = ({
|
||||
delayLongPress,
|
||||
swipeToCloseEnabled = true,
|
||||
doubleTapToZoomEnabled = true,
|
||||
pinchRef,
|
||||
}: Props) => {
|
||||
const [isScaled, setIsScaled] = useState(false)
|
||||
const [isLoaded, setIsLoaded] = useState(false)
|
||||
@@ -223,6 +224,7 @@ const ImageItem = ({
|
||||
}
|
||||
|
||||
const pinch = Gesture.Pinch()
|
||||
.withRef(pinchRef)
|
||||
.onStart((e) => {
|
||||
pinchOrigin.value = {
|
||||
x: e.focalX - SCREEN.width/2,
|
||||
|
||||
@@ -110,6 +110,13 @@ function ImageViewing({
|
||||
}
|
||||
}, [imageList, imageIndex])
|
||||
|
||||
const [pinchRefs] = useState(new Map())
|
||||
for (let imageSrc of images) {
|
||||
if (!pinchRefs.get(imageSrc)) {
|
||||
pinchRefs.set(imageSrc, createRef())
|
||||
}
|
||||
}
|
||||
|
||||
if (!visible) {
|
||||
return null
|
||||
}
|
||||
@@ -156,8 +163,15 @@ function ImageViewing({
|
||||
delayLongPress={delayLongPress}
|
||||
swipeToCloseEnabled={swipeToCloseEnabled}
|
||||
doubleTapToZoomEnabled={doubleTapToZoomEnabled}
|
||||
pinchRef={pinchRefs.get(imageSrc)}
|
||||
/>
|
||||
)}
|
||||
renderScrollComponent={props => (
|
||||
<ScrollView
|
||||
{...props}
|
||||
waitFor={Array.from(pinchRefs.values())}
|
||||
/>
|
||||
)}
|
||||
onMomentumScrollEnd={onScroll}
|
||||
//@ts-ignore
|
||||
keyExtractor={(imageSrc, index) =>
|
||||
|
||||
Reference in New Issue
Block a user