Skip to content

Commit b0792de

Browse files
committed
fix: fixed the backdrop tap gesture on web (#1446)
1 parent 96b9088 commit b0792de

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx

+10-19
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@ import React, {
99
import { ViewProps } from 'react-native';
1010
import Animated, {
1111
interpolate,
12-
Extrapolate,
1312
useAnimatedStyle,
1413
useAnimatedReaction,
15-
useAnimatedGestureHandler,
1614
runOnJS,
15+
Extrapolation,
1716
} from 'react-native-reanimated';
18-
import {
19-
TapGestureHandler,
20-
TapGestureHandlerGestureEvent,
21-
} from 'react-native-gesture-handler';
17+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
2218
import { useBottomSheet } from '../../hooks';
2319
import {
2420
DEFAULT_OPACITY,
@@ -91,15 +87,12 @@ const BottomSheetBackdropComponent = ({
9187
//#endregion
9288

9389
//#region tap gesture
94-
const gestureHandler =
95-
useAnimatedGestureHandler<TapGestureHandlerGestureEvent>(
96-
{
97-
onFinish: () => {
98-
runOnJS(handleOnPress)();
99-
},
100-
},
101-
[handleOnPress]
102-
);
90+
const tapHandler = useMemo(() => {
91+
let gesture = Gesture.Tap().onEnd(() => {
92+
runOnJS(handleOnPress)();
93+
});
94+
return gesture;
95+
}, [handleOnPress]);
10396
//#endregion
10497

10598
//#region styles
@@ -108,7 +101,7 @@ const BottomSheetBackdropComponent = ({
108101
animatedIndex.value,
109102
[-1, disappearsOnIndex, appearsOnIndex],
110103
[0, 0, opacity],
111-
Extrapolate.CLAMP
104+
Extrapolation.CLAMP
112105
),
113106
flex: 1,
114107
}));
@@ -160,9 +153,7 @@ const BottomSheetBackdropComponent = ({
160153
);
161154

162155
return pressBehavior !== 'none' ? (
163-
<TapGestureHandler onGestureEvent={gestureHandler}>
164-
{AnimatedView}
165-
</TapGestureHandler>
156+
<GestureDetector gesture={tapHandler}>{AnimatedView}</GestureDetector>
166157
) : (
167158
AnimatedView
168159
);

0 commit comments

Comments
 (0)