react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

Pan Gesture event

Open Livijn opened this issue 2 years ago • 5 comments

Feature Request

Why it is needed

This might be a feature request, or perhaps it's already available. I am trying to respond to the pan gesture. Basically, when the sheet is panned larger/smaller, I want another item to shrink / expand.

I've looked at the gestureEventsHandlersHook prop and this hook with no luck: https://github.com/gorhom/react-native-bottom-sheet/blob/e15965f18ca90a45a34f963e57df3eb83f22444b/src/hooks/useGestureEventsHandlersDefault.tsx#L23

Is there a way to do this atm?

Possible implementation

Perhaps a onPanStart and onPanEnd event.

Code sample

No idea

Livijn avatar Jun 18 '22 11:06 Livijn

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 19 '22 09:07 github-actions[bot]

bump

Livijn avatar Jul 19 '22 09:07 Livijn

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 19 '22 09:08 github-actions[bot]

bump

Livijn avatar Aug 21 '22 20:08 Livijn

Any news?

Marbos21 avatar Sep 08 '22 13:09 Marbos21

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 09 '22 09:10 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Oct 14 '22 09:10 github-actions[bot]

Why this request has been closed? This feature can be very useful to someone ho need to perform an action when the bottom sheet is dragged

g-m-99 avatar Aug 08 '23 14:08 g-m-99

any luck ?

w4t3r-45 avatar Oct 03 '23 14:10 w4t3r-45

I ended up creating a local copy of useCustomerGestureEventsHandlers, making modifications to it, and then passing it in as a prop: gestureEventsHandlersHook={useCustomGestureEventsHandlers}

bewallyt avatar Feb 17 '24 17:02 bewallyt

Hi, @bewallyt! Could you help me with an example of how to use useCustomerGestureEventsHandlers ? I copied it from https://github.com/gorhom/react-native-bottom-sheet/blob/master/example/app/src/screens/advanced/customGestureHandling/useCustomGestureEventsHandlers.ts modified it to accept an onStart prop and I'm trying to use it like:

 <BottomSheet
 ...
     gestureEventsHandlersHook={useCustomGestureEventsHandlers({
       onStart: () => { console.log("ON START") },
      })}
      ...

Result: not working, the app crashes and closes automatically. I'm missing something...

How can I know when the handleOnStart drag event triggered ?

AndreiTimofte96 avatar Apr 24 '24 23:04 AndreiTimofte96

@AndreiTimofte96

does it make sense to just modify the built in handleOnStart (i.e., add a log statement) before trying to add an additional onStart prop?

bewallyt avatar Apr 25 '24 14:04 bewallyt

@bewallyt adding a log statement isn't enough for my use case. I need to have acces from outside of that hook. My use case is that I want to control the content displayed inside the BottomSheet. So I would need to pass (somehow) an onDragStart callback to the BottomSheet.

 const [content, setContent] = useState("before drag content");

  return (
    <BottomSheet
      gestureEventsHandlersHook={useCustomGestureEventsHandlers({
      onStart: () => {setContent("after drag content")},
      })}
      ref={bottomSheetRef}
      snapPoints={[
        bottomSheetHeightRef.current,
        bottomSheetHeightRef.current + 5,
        '90%',
      ]}
    >
      <BottomSheetView style={styles.bottomSheet}>
        {content}
        </BottomSheetView>
        ........

Any help would be highly appreciated! Thank you!

AndreiTimofte96 avatar Apr 25 '24 14:04 AndreiTimofte96

can i see how onStart is implemented in your useCustomGestureEventsHandlers?

bewallyt avatar Apr 25 '24 14:04 bewallyt

@bewallyt

image

AndreiTimofte96 avatar Apr 25 '24 14:04 AndreiTimofte96

maybe try invoking on start when it meets some threshold of translation y

bewallyt avatar Apr 25 '24 14:04 bewallyt