Force zoom out before close
It's too hard to make closing while zoomed out work.
This commit is contained in:
@@ -236,6 +236,13 @@ const ImageItem = ({
|
||||
|
||||
const singleTap = Gesture.Tap().onEnd(() => {
|
||||
'worklet'
|
||||
const [, , committedScale] = readTransform(committedTransform.value)
|
||||
if (committedScale !== 1) {
|
||||
// Go back to 1:1 using the identity vector.
|
||||
let t = createTransform()
|
||||
committedTransform.value = withClampedSpring(t)
|
||||
return
|
||||
}
|
||||
runOnJS(onTap)()
|
||||
})
|
||||
|
||||
|
||||
@@ -97,9 +97,25 @@ const ImageItem = ({
|
||||
})
|
||||
}
|
||||
|
||||
function handleTap() {
|
||||
if (scaled) {
|
||||
const scrollResponderRef = scrollViewRef?.current?.getScrollResponder()
|
||||
// @ts-ignore
|
||||
scrollResponderRef?.scrollResponderZoomTo({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: SCREEN.width,
|
||||
height: SCREEN.height,
|
||||
animated: true,
|
||||
})
|
||||
} else {
|
||||
onTap()
|
||||
}
|
||||
}
|
||||
|
||||
const singleTap = Gesture.Tap().onEnd(() => {
|
||||
'worklet'
|
||||
runOnJS(onTap)()
|
||||
runOnJS(handleTap)()
|
||||
})
|
||||
|
||||
const doubleTap = Gesture.Tap()
|
||||
|
||||
Reference in New Issue
Block a user