Force zoom out before close

It's too hard to make closing while zoomed out work.
This commit is contained in:
Dan Abramov
2024-11-03 03:05:04 +00:00
parent bed486f508
commit caeb86a368
2 changed files with 24 additions and 1 deletions
@@ -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()