Fix stuck lightbox header after double tap (#1627)

zio/stable
dan 2023-10-06 04:22:32 +01:00 committed by GitHub
parent 3b78d3227f
commit d2f11f8e36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 9 deletions

View File

@ -61,16 +61,21 @@ const ImageItem = ({
const dismissSwipeTranslateY = useSharedValue(0) const dismissSwipeTranslateY = useSharedValue(0)
const containerRef = useAnimatedRef() const containerRef = useAnimatedRef()
function getCommittedScale(): number {
'worklet'
const [, , committedScale] = readTransform(committedTransform.value)
return committedScale
}
// Keep track of when we're entering or leaving scaled rendering. // Keep track of when we're entering or leaving scaled rendering.
// Note: DO NOT move any logic reading animated values outside this function.
useAnimatedReaction( useAnimatedReaction(
() => { () => {
return pinchScale.value !== 1 || getCommittedScale() !== 1 if (pinchScale.value !== 1) {
// We're currently pinching.
return true
}
const [, , committedScale] = readTransform(committedTransform.value)
if (committedScale !== 1) {
// We started from a pinched in state.
return true
}
// We're at rest.
return false
}, },
(nextIsScaled, prevIsScaled) => { (nextIsScaled, prevIsScaled) => {
if (nextIsScaled !== prevIsScaled) { if (nextIsScaled !== prevIsScaled) {
@ -169,7 +174,7 @@ const ImageItem = ({
} }
// Don't let the picture zoom in so close that it gets blurry. // Don't let the picture zoom in so close that it gets blurry.
// Also, like in stock Android apps, don't let the user zoom out further than 1:1. // Also, like in stock Android apps, don't let the user zoom out further than 1:1.
const committedScale = getCommittedScale() const [, , committedScale] = readTransform(committedTransform.value)
const maxCommittedScale = const maxCommittedScale =
(imageDimensions.width / SCREEN.width) * MAX_ORIGINAL_IMAGE_ZOOM (imageDimensions.width / SCREEN.width) * MAX_ORIGINAL_IMAGE_ZOOM
const minPinchScale = 1 / committedScale const minPinchScale = 1 / committedScale
@ -256,7 +261,7 @@ const ImageItem = ({
if (!imageDimensions) { if (!imageDimensions) {
return return
} }
const committedScale = getCommittedScale() const [, , committedScale] = readTransform(committedTransform.value)
if (committedScale !== 1) { if (committedScale !== 1) {
// Go back to 1:1 using the identity vector. // Go back to 1:1 using the identity vector.
let t = createTransform() let t = createTransform()