Show/hide controls on zoom

This commit is contained in:
Dan Abramov
2023-09-29 17:28:38 +01:00
parent 0f86c5f7b6
commit c360c5c922
2 changed files with 8 additions and 5 deletions
@@ -180,13 +180,18 @@ const ImageItem = ({
} }
return false; return false;
}, },
(isScaledNow, wasScaledBefore) => { (nextIsScaled, prevIsScaled) => {
if (isScaledNow !== wasScaledBefore) { if (nextIsScaled !== prevIsScaled) {
runOnJS(setIsScaled)(isScaledNow) runOnJS(handleZoom)(nextIsScaled)
} }
} }
) )
function handleZoom(nextIsScaled) {
setIsScaled(nextIsScaled)
onZoom(nextIsScaled)
}
const animatedStyle = useAnimatedStyle(() => { const animatedStyle = useAnimatedStyle(() => {
let t = createTransform(); let t = createTransform();
prependPan(t, panTranslation.value); prependPan(t, panTranslation.value);
@@ -87,8 +87,6 @@ function ImageViewing({
const onZoom = useCallback( const onZoom = useCallback(
(isScaled: boolean) => { (isScaled: boolean) => {
// @ts-ignore
imageList?.current?.setNativeProps({scrollEnabled: !isScaled})
toggleBarsVisible(!isScaled) toggleBarsVisible(!isScaled)
}, },
[toggleBarsVisible], [toggleBarsVisible],