From 2e74b1691c4b29e64cdae63492bc1003d1477402 Mon Sep 17 00:00:00 2001 From: Marcos Carpio Date: Tue, 2 Dec 2025 12:14:10 -0300 Subject: [PATCH 1/2] Added onSwipeableDragEnd property --- .../docs/components/reanimated_swipeable.md | 5 +++++ .../components/ReanimatedSwipeable/ReanimatedSwipeable.tsx | 5 +++++ .../ReanimatedSwipeable/ReanimatedSwipeableProps.ts | 7 +++++++ 3 files changed, 17 insertions(+) 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..d6b76644f9 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)(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. */ From 9e5291b0fbf0083e22a8eaa510f4c9865d23073e Mon Sep 17 00:00:00 2001 From: Marcos Carpio Date: Tue, 2 Dec 2025 12:20:10 -0300 Subject: [PATCH 2/2] Fix for values lower than -0 --- .../src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d6b76644f9..8dc4695fbf 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +++ b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx @@ -459,7 +459,7 @@ const Swipeable = (props: SwipeableProps) => { } if(onSwipeableDragEnd){ - runOnJS(onSwipeableDragEnd)(Object.is(toValue, -0) ? SwipeDirection.RIGHT : SwipeDirection.LEFT); + runOnJS(onSwipeableDragEnd)(toValue < 0 || Object.is(toValue, -0) ? SwipeDirection.RIGHT : SwipeDirection.LEFT); } animateRow(toValue, velocityX / friction);