Skip to content

Commit 97611c8

Browse files
authored
fix: image tap functionality on android (#3272)
* Fix image tap issue on android devices * revert changes * Fix image tap issue by adding min distance threshold
1 parent b795fa5 commit 97611c8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

package/src/components/Message/MessageSimple/MessageBubble.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export const SwipableMessageBubble = React.memo(
101101
);
102102

103103
const SWIPABLE_THRESHOLD = 25;
104+
const MINIMUM_DISTANCE = 8;
104105

105106
const triggerHaptic = NativeHandlers.triggerHaptic;
106107

@@ -120,14 +121,17 @@ export const SwipableMessageBubble = React.memo(
120121
const xDiff = Math.abs(event.changedTouches[0].x - touchStart.value.x);
121122
const yDiff = Math.abs(event.changedTouches[0].y - touchStart.value.y);
122123
const isHorizontalPanning = xDiff > yDiff;
124+
const hasMinimumDistance = xDiff > MINIMUM_DISTANCE || yDiff > MINIMUM_DISTANCE;
123125

124-
if (isHorizontalPanning) {
126+
// Only activate if there's significant horizontal movement
127+
if (isHorizontalPanning && hasMinimumDistance) {
125128
state.activate();
126129
isSwiping.value = true;
127130
if (!shouldRenderSwipeableWrapper) {
128131
runOnJS(setShouldRenderAnimatedWrapper)(isSwiping.value);
129132
}
130-
} else {
133+
} else if (hasMinimumDistance) {
134+
// If there's significant movement but not horizontal, fail the gesture
131135
state.fail();
132136
}
133137
})

0 commit comments

Comments
 (0)