Skip to content
TypeScript

fix(mobile): Android image viewer keeps panning after an interrupted pinch (#19241)

Quy Ngoc Nguyenc5520b52ecba
diff --git a/patches/[email protected] b/patches/[email protected]
index 6e2b719704e..f85cb5fea13 100644
--- a/patches/[email protected]
+++ b/patches/[email protected]
@@ -89,12 +89,16 @@ index 5fcaa9f9a7d893817fee89b85186ee3936118e69..3effe838fa54495d165b81cc7501e72d
const imageContainer = useRef(null);
const imageDimensions = useImageDimensions(imageSrc);
const [translate, scale] = getImageTransform(imageDimensions, SCREEN);
-@@ -31,7 +31,7 @@ const ImageItem = ({ imageSrc, onZoom, onRequestClose, onLongPress, delayLongPre
- scrollEnabled: !isZoomed,
+@@ -28,10 +28,10 @@ const ImageItem = ({ imageSrc, onZoom, onRequestClose, onLongPress, delayLongPre
+ onZoom(isZoomed);
+ if ((_a = imageContainer) === null || _a === void 0 ? void 0 : _a.current) {
+ imageContainer.current.setNativeProps({
+- scrollEnabled: !isZoomed,
++ scrollEnabled: swipeToCloseEnabled && !isZoomed,
});
}
- }, [imageContainer]);
-+ }, [imageContainer, onZoom]);
++ }, [imageContainer, onZoom, swipeToCloseEnabled]);
const onLongPressHandler = useCallback(() => {
onLongPress(imageSrc);
}, [imageSrc, onLongPress]);
@@ -272,3 +276,13 @@ index 99dcbc7efea4eba86a8bc2bad71dde73c8ebf1b4..3a374c0923879548ec3826a78be16f79
let numberInitialTouches = 1;
let initialTouches = [];
let currentScale = initialScale;
+@@ -266,6 +266,9 @@ const usePanResponder = ({ initialScale, initialTranslate, onZoom, doubleTapToZo
+ tmpTranslate = null;
+ }
+ },
++ // A gesture taken over mid-pinch must commit like a release, or pans stay
++ // gated on the pre-pinch scale while the image still shows zoomed.
++ onTerminate: () => handlers.onRelease(),
+ };
+ const panResponder = useMemo(() => createPanResponder(handlers), [handlers]);
+ return [panResponder.panHandlers, scaleValue, translateValue];
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 56ceb3b1653..ed0d90e7639 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -189,7 +189,7 @@ patchedDependencies:
[email protected]: 49ab4815c18b003f6af998dcc6c258c17a21b50b2cc87745f12d4bd8b6d591f9
[email protected]: f1e680afec85f650699ea756f91f469844ec4c976f4f168492a45c6b3f67d651
[email protected]: abe20e1d1c23549297cbbc818e14fe479b41455930d9663135d6b40fe359b626
- [email protected]: a479085493f2404ecdefea18f46c6be3ad49cfb54da8e78dc7746651263cb5a0
+ [email protected]: 419f35ee91eac88ced9438058281db5eb09d9c799d8974c1172926068c9448cf
[email protected]: f28d08f1233e3cce8b9324b4357d2b10f1ee040b8051bc87235b0fb95069b9bb
[email protected]: 6f52854210f61bef499850ebd498229a111bc34ec5b2a4925e644f2f48f42760
[email protected]: 81caa279ec3dc1f81209062133b66e8f824e13f106cca57f1fa732a72c2ab378
@@ -574,7 +574,7 @@ importers:
version: 3.3.0(patch_hash=abe20e1d1c23549297cbbc818e14fe479b41455930d9663135d6b40fe359b626)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
react-native-image-viewing:
specifier: ^0.2.2
- version: 0.2.2(patch_hash=a479085493f2404ecdefea18f46c6be3ad49cfb54da8e78dc7746651263cb5a0)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
+ version: 0.2.2(patch_hash=419f35ee91eac88ced9438058281db5eb09d9c799d8974c1172926068c9448cf)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
react-native-keyboard-controller:
specifier: 1.22.7
@@ -22604,7 +22604,7 @@ snapshots:
react: 19.3.0
dependencies:
react: 19.3.0