diff --git a/packages/docs-gesture-handler/docs/components/reanimated_swipeable.md b/packages/docs-gesture-handler/docs/components/reanimated_swipeable.md index bbf58d07fc..8c43349381 100644 --- a/packages/docs-gesture-handler/docs/components/reanimated_swipeable.md +++ b/packages/docs-gesture-handler/docs/components/reanimated_swipeable.md @@ -80,6 +80,11 @@ Receives swipe direction as an argument. a function that is called when `swipeable` starts animating on close. Receives swipe direction as an argument. +### `onSwipeableDragEnd` + +a function that is called when `swipeable` ends dragging. +Receives swipe direction as an argument. + ### `onSwipeableOpenStartDrag` a function that is called when a user starts to drag the `swipable` to open. diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx index a1c840e173..8dc4695fbf 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +++ b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx @@ -66,6 +66,7 @@ const Swipeable = (props: SwipeableProps) => { onSwipeableWillClose, onSwipeableOpen, onSwipeableClose, + onSwipeableDragEnd, renderLeftActions, renderRightActions, simultaneousWithExternalGesture, @@ -457,6 +458,10 @@ const Swipeable = (props: SwipeableProps) => { } } + if(onSwipeableDragEnd){ + runOnJS(onSwipeableDragEnd)(toValue < 0 || Object.is(toValue, -0) ? SwipeDirection.RIGHT : SwipeDirection.LEFT); + } + animateRow(toValue, velocityX / friction); }, [ diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts index f81877d1b2..448c6a2282 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +++ b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts @@ -126,6 +126,13 @@ export interface SwipeableProps { direction: SwipeDirection.LEFT | SwipeDirection.RIGHT ) => void; + /** + * Called when action panel drag ends. + */ + onSwipeableDragEnd?: ( + direction: SwipeDirection.LEFT | SwipeDirection.RIGHT + ) => void; + /** * Called when action panel starts being shown on dragging to open. */