Open History to see the last commit
1diff --git a/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js b/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js
2index 551ab92bf58db0b79d428dcd2f2df898ef686493..13db26d88bff975bc5d46bb6432cbf9fda3d489a 100644
3--- a/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js
4+++ b/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js
5@@ -34,11 +34,13 @@ const Swipeable = props => {
6 enableTrackpadTwoFingerGesture = DEFAULT_ENABLE_TRACKING_TWO_FINGER_GESTURE,
7 dragOffsetFromLeftEdge = DEFAULT_DRAG_OFFSET,
8 dragOffsetFromRightEdge = DEFAULT_DRAG_OFFSET,
9+ failOffsetY,
10 friction = DEFAULT_FRICTION,
11 overshootFriction = DEFAULT_OVERSHOOT_FRICTION,
12 onSwipeableOpenStartDrag,
13 onSwipeableCloseStartDrag,
14 onSwipeableWillOpen,
15+ onSwipeableRelease,
16 onSwipeableWillClose,
17 onSwipeableOpen,
18 onSwipeableClose,
19@@ -248,8 +250,13 @@ const Swipeable = props => {
20 toValue = -rightWidth.value;
21 }
22 }
23+ // Let a UI-thread full-swipe commit take over before the return spring.
24+ if (onSwipeableRelease?.(appliedTranslation)) {
25+ return;
26+ }
27+
28 animateRow(toValue, velocityX / friction);
29- }, [animateRow, friction, leftThreshold, leftWidth, rightThreshold, rightWidth, rowState, userDrag]);
30+ }, [animateRow, friction, leftThreshold, leftWidth, rightThreshold, rightWidth, rowState, userDrag, onSwipeableRelease, appliedTranslation]);
31 const close = (0, _react.useCallback)(() => {
32 'worklet';
34@@ -285,11 +292,14 @@ const Swipeable = props => {
35 }).onFinalize(() => {
36 dragStarted.value = false;
37 });
38+ if (failOffsetY !== undefined) {
39+ pan.failOffsetY(failOffsetY);
40+ }
41 Object.entries(relationProps).forEach(([relationName, relation]) => {
42 (0, _utils.applyRelationProp)(pan, relationName, relation);
43 });
44 return pan;
45- }, [enabled, hitSlop, enableTrackpadTwoFingerGesture, dragOffsetFromRightEdge, dragOffsetFromLeftEdge, updateElementWidths, relationProps, userDrag, rowState, dragStarted, updateAnimatedEvent, onSwipeableOpenStartDrag, onSwipeableCloseStartDrag, handleRelease]);
46+ }, [enabled, hitSlop, enableTrackpadTwoFingerGesture, dragOffsetFromRightEdge, dragOffsetFromLeftEdge, failOffsetY, updateElementWidths, relationProps, userDrag, rowState, dragStarted, updateAnimatedEvent, onSwipeableOpenStartDrag, onSwipeableCloseStartDrag, handleRelease]);
47 (0, _react.useImperativeHandle)(ref, () => swipeableMethods, [swipeableMethods]);
48 const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
49 transform: [{
50diff --git a/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js b/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js
51index a2835d5416ffd5cf9a04e98774516b9e6569691e..055afce410d6eb655532e7a09371dfc22eae5e9c 100644
52--- a/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js
53+++ b/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js
54@@ -29,11 +29,13 @@ const Swipeable = props => {
55 enableTrackpadTwoFingerGesture = DEFAULT_ENABLE_TRACKING_TWO_FINGER_GESTURE,
56 dragOffsetFromLeftEdge = DEFAULT_DRAG_OFFSET,
57 dragOffsetFromRightEdge = DEFAULT_DRAG_OFFSET,
58+ failOffsetY,
59 friction = DEFAULT_FRICTION,
60 overshootFriction = DEFAULT_OVERSHOOT_FRICTION,
61 onSwipeableOpenStartDrag,
62 onSwipeableCloseStartDrag,
63 onSwipeableWillOpen,
64+ onSwipeableRelease,
65 onSwipeableWillClose,
66 onSwipeableOpen,
67 onSwipeableClose,
68@@ -243,8 +245,13 @@ const Swipeable = props => {
69 toValue = -rightWidth.value;
70 }
71 }
72+ // Let a UI-thread full-swipe commit take over before the return spring.
73+ if (onSwipeableRelease?.(appliedTranslation)) {
74+ return;
75+ }
76+
77 animateRow(toValue, velocityX / friction);
78- }, [animateRow, friction, leftThreshold, leftWidth, rightThreshold, rightWidth, rowState, userDrag]);
79+ }, [animateRow, friction, leftThreshold, leftWidth, rightThreshold, rightWidth, rowState, userDrag, onSwipeableRelease, appliedTranslation]);
80 const close = useCallback(() => {
81 'worklet';
83@@ -280,11 +287,14 @@ const Swipeable = props => {
84 }).onFinalize(() => {
85 dragStarted.value = false;
86 });
87+ if (failOffsetY !== undefined) {
88+ pan.failOffsetY(failOffsetY);
89+ }
90 Object.entries(relationProps).forEach(([relationName, relation]) => {
91 applyRelationProp(pan, relationName, relation);
92 });
93 return pan;
94- }, [enabled, hitSlop, enableTrackpadTwoFingerGesture, dragOffsetFromRightEdge, dragOffsetFromLeftEdge, updateElementWidths, relationProps, userDrag, rowState, dragStarted, updateAnimatedEvent, onSwipeableOpenStartDrag, onSwipeableCloseStartDrag, handleRelease]);
95+ }, [enabled, hitSlop, enableTrackpadTwoFingerGesture, dragOffsetFromRightEdge, dragOffsetFromLeftEdge, failOffsetY, updateElementWidths, relationProps, userDrag, rowState, dragStarted, updateAnimatedEvent, onSwipeableOpenStartDrag, onSwipeableCloseStartDrag, handleRelease]);
96 useImperativeHandle(ref, () => swipeableMethods, [swipeableMethods]);
97 const animatedStyle = useAnimatedStyle(() => ({
98 transform: [{
99diff --git a/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts b/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts
100index ac8b76830d468edfbc29052b452a36221323c3de..6985d54d9d359e825a5a0e6078bb113204e2807b 100644
101--- a/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts
102+++ b/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts
103@@ -64,6 +64,13 @@ export interface SwipeableProps {
104 * a swipe. The default value is 10.
105 */
106 dragOffsetFromRightEdge?: number;
107+ /**
108+ * Range along the Y axis (in points) that, once exceeded before the swipe
109+ * activates, makes the pan fail. Lets vertically-dominant pans (list
110+ * scrolling, especially trackpad two-finger pans) skip the swipe entirely.
111+ * Passed straight to the underlying Pan gesture's `failOffsetY`.
112+ */
113+ failOffsetY?: number | [start: number, end: number];
114 /**
115 * Value indicating if the swipeable panel can be pulled further than the left
116 * actions panel's width. It is set to true by default as long as the left
117@@ -90,6 +97,13 @@ export interface SwipeableProps {
118 * Called when action panel is closed.
119 */
120 onSwipeableClose?: (direction: SwipeDirection.LEFT | SwipeDirection.RIGHT) => void;
121+ /**
122+ * UI-thread worklet called on release before the built-in spring starts.
123+ * Return true to consume the release and take ownership of translation.
124+ * The caller must reset or remove the row after its custom animation.
125+ */
126+ onSwipeableRelease?: (translation: SharedValue<number>) => boolean;
127+
128 /**
129 * Called when action panel starts animating on open (either right or left).
130 */
131diff --git a/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx b/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx
132index b6134c908624adc590ebd264e90e558b88e235d5..fa4b1c1749bd0e86cbf5f5546f295d8099e1a481 100644
133--- a/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx
134+++ b/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx
135@@ -58,11 +58,13 @@ const Swipeable = (props: SwipeableProps) => {
136 enableTrackpadTwoFingerGesture = DEFAULT_ENABLE_TRACKING_TWO_FINGER_GESTURE,
137 dragOffsetFromLeftEdge = DEFAULT_DRAG_OFFSET,
138 dragOffsetFromRightEdge = DEFAULT_DRAG_OFFSET,
139+ failOffsetY,
140 friction = DEFAULT_FRICTION,
141 overshootFriction = DEFAULT_OVERSHOOT_FRICTION,
142 onSwipeableOpenStartDrag,
143 onSwipeableCloseStartDrag,
144 onSwipeableWillOpen,
145+ onSwipeableRelease,
146 onSwipeableWillClose,
147 onSwipeableOpen,
148 onSwipeableClose,
149@@ -457,6 +459,11 @@ const Swipeable = (props: SwipeableProps) => {
150 }
151 }
153+ // Let a UI-thread full-swipe commit take over before the return spring.
154+ if (onSwipeableRelease?.(appliedTranslation)) {
155+ return;
156+ }
157+
158 animateRow(toValue, velocityX / friction);
159 },
160 [
161@@ -468,6 +475,8 @@ const Swipeable = (props: SwipeableProps) => {
162 rightWidth,
163 rowState,
164 userDrag,
165+ onSwipeableRelease,
166+ appliedTranslation,
167 ]
168 );
170@@ -537,6 +546,10 @@ const Swipeable = (props: SwipeableProps) => {
171 dragStarted.value = false;
172 });
174+ if (failOffsetY !== undefined) {
175+ pan.failOffsetY(failOffsetY);
176+ }
177+
178 Object.entries(relationProps).forEach(([relationName, relation]) => {
179 applyRelationProp(
180 pan,
181@@ -552,6 +565,7 @@ const Swipeable = (props: SwipeableProps) => {
182 enableTrackpadTwoFingerGesture,
183 dragOffsetFromRightEdge,
184 dragOffsetFromLeftEdge,
185+ failOffsetY,
186 updateElementWidths,
187 relationProps,
188 userDrag,
189diff --git a/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts b/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts
190index 0c0e517e0d340faf50ff78c3d48e7a2bbcf808ec..3ab14d240da346b1927792e480f5b1e902b03bf8 100644
191--- a/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts
192+++ b/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts
193@@ -77,6 +77,14 @@ export interface SwipeableProps {
194 */
195 dragOffsetFromRightEdge?: number;
197+ /**
198+ * Range along the Y axis (in points) that, once exceeded before the swipe
199+ * activates, makes the pan fail. Lets vertically-dominant pans (list
200+ * scrolling, especially trackpad two-finger pans) skip the swipe entirely.
201+ * Passed straight to the underlying Pan gesture's `failOffsetY`.
202+ */
203+ failOffsetY?: number | [start: number, end: number];
204+
205 /**
206 * Value indicating if the swipeable panel can be pulled further than the left
207 * actions panel's width. It is set to true by default as long as the left
208@@ -112,6 +120,13 @@ export interface SwipeableProps {
209 direction: SwipeDirection.LEFT | SwipeDirection.RIGHT
210 ) => void;
212+ /**
213+ * UI-thread worklet called on release before the built-in spring starts.
214+ * Return true to consume the release and take ownership of translation.
215+ * The caller must reset or remove the row after its custom animation.
216+ */
217+ onSwipeableRelease?: (translation: SharedValue<number>) => boolean;
218+
219 /**
220 * Called when action panel starts animating on open (either right or left).
221 */