Skip to content

Commit

Permalink
More precise scroll dragging protection
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Oct 5, 2023
1 parent 9abe15f commit 26183ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const ImageItem = ({
delayLongPress,
swipeToCloseEnabled = true,
doubleTapToZoomEnabled = true,
isDragging,
gestureRef,
}: Props) => {
const [isScaled, setIsScaled] = useState(false)
Expand Down Expand Up @@ -228,12 +229,16 @@ const ImageItem = ({

const consumeHScroll = Gesture.Manual()
.onTouchesDown((e, manager) => {
if (isDragging) {
manager.activate();
return;
}
const measurement = measure(containerRef);
if (!measurement || measurement.pageX !== 0) {
manager.activate();
} else {
manager.fail();
return;
}
manager.fail();
})

const pinch = Gesture.Pinch()
Expand Down
1 change: 1 addition & 0 deletions src/view/com/lightbox/ImageViewing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function ImageViewing({
swipeToCloseEnabled={swipeToCloseEnabled}
doubleTapToZoomEnabled={doubleTapToZoomEnabled}
gestureRef={gestureRefs.get(imageSrc)}
isDragging={isDragging}
/>
)}
renderScrollComponent={props => (
Expand Down

0 comments on commit 26183ee

Please sign in to comment.