Skip to content

Commit

Permalink
fix: fixed the backdrop tap gesture on web (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Jan 3, 2024
1 parent 96b9088 commit b0792de
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ import React, {
import { ViewProps } from 'react-native';
import Animated, {
interpolate,
Extrapolate,
useAnimatedStyle,
useAnimatedReaction,
useAnimatedGestureHandler,
runOnJS,
Extrapolation,
} from 'react-native-reanimated';
import {
TapGestureHandler,
TapGestureHandlerGestureEvent,
} from 'react-native-gesture-handler';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import { useBottomSheet } from '../../hooks';
import {
DEFAULT_OPACITY,
Expand Down Expand Up @@ -91,15 +87,12 @@ const BottomSheetBackdropComponent = ({
//#endregion

//#region tap gesture
const gestureHandler =
useAnimatedGestureHandler<TapGestureHandlerGestureEvent>(
{
onFinish: () => {
runOnJS(handleOnPress)();
},
},
[handleOnPress]
);
const tapHandler = useMemo(() => {
let gesture = Gesture.Tap().onEnd(() => {
runOnJS(handleOnPress)();
});
return gesture;
}, [handleOnPress]);
//#endregion

//#region styles
Expand All @@ -108,7 +101,7 @@ const BottomSheetBackdropComponent = ({
animatedIndex.value,
[-1, disappearsOnIndex, appearsOnIndex],
[0, 0, opacity],
Extrapolate.CLAMP
Extrapolation.CLAMP
),
flex: 1,
}));
Expand Down Expand Up @@ -160,9 +153,7 @@ const BottomSheetBackdropComponent = ({
);

return pressBehavior !== 'none' ? (
<TapGestureHandler onGestureEvent={gestureHandler}>
{AnimatedView}
</TapGestureHandler>
<GestureDetector gesture={tapHandler}>{AnimatedView}</GestureDetector>
) : (
AnimatedView
);
Expand Down

0 comments on commit b0792de

Please sign in to comment.