Skip to content

Commit f8e2803

Browse files
authored
Fix: dragging a zoomed-out image right does not navigate back (#978)
1 parent d050f0e commit f8e2803

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

components/pinchy.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@ const Pinchy = ({uuid}: {uuid: string}) => {
125125

126126
const renderedImageSize = useRef({imageWidth: 0, imageHeight: 0});
127127

128+
const [isZoomed, setIsZoomed] = useState(false);
129+
128130
const setScale = (s: number) => {
129131
scale.current = s;
130132
animatedScale.current.setValue(s);
133+
setIsZoomed(s > 1 + 1e-5);
131134
};
132135

133136
const setPosition = (p: {x: number, y: number}) => {
@@ -164,6 +167,7 @@ const Pinchy = ({uuid}: {uuid: string}) => {
164167
const pan = useMemo(
165168
() => Gesture.Pan()
166169
.runOnJS(true)
170+
.enabled(isZoomed)
167171
.onStart(() => {
168172
positionBase.current = { ...position.current };
169173
})
@@ -181,7 +185,7 @@ const Pinchy = ({uuid}: {uuid: string}) => {
181185
.onEnd(() => {
182186
positionBase.current = null;
183187
}),
184-
[],
188+
[isZoomed],
185189
);
186190

187191
const pinch = useMemo(

0 commit comments

Comments
 (0)