react-native-gesture-handler 2.22.0 → 2.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/ReanimatedSwipeable.js +80 -47
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/handlers/createNativeWrapper.js +17 -6
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -1
- package/lib/module/components/ReanimatedSwipeable.js +81 -48
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/handlers/createNativeWrapper.js +17 -6
- package/lib/module/handlers/createNativeWrapper.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ReanimatedSwipeable.tsx +101 -51
- package/src/handlers/createNativeWrapper.tsx +10 -4
@@ -6,7 +6,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
6
6
|
import React, { forwardRef, useCallback, useImperativeHandle, useMemo } from 'react';
|
7
7
|
import { GestureObjects as Gesture } from '../handlers/gestures/gestureObjects';
|
8
8
|
import { GestureDetector } from '../handlers/gestures/GestureDetector';
|
9
|
-
import Animated, { interpolate, runOnJS, useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
|
9
|
+
import Animated, { ReduceMotion, interpolate, measure, runOnJS, runOnUI, useAnimatedRef, useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
|
10
10
|
import { I18nManager, StyleSheet, View } from 'react-native';
|
11
11
|
const DRAG_TOSS = 0.05;
|
12
12
|
var SwipeDirection;
|
@@ -54,20 +54,9 @@ const Swipeable = /*#__PURE__*/forwardRef(function Swipeable(props, ref) {
|
|
54
54
|
const appliedTranslation = useSharedValue(0);
|
55
55
|
const rowWidth = useSharedValue(0);
|
56
56
|
const leftWidth = useSharedValue(0);
|
57
|
-
const rightWidth = useSharedValue(0);
|
58
|
-
|
59
|
-
const rightOffset = useSharedValue(null);
|
57
|
+
const rightWidth = useSharedValue(0);
|
60
58
|
const showLeftProgress = useSharedValue(0);
|
61
59
|
const showRightProgress = useSharedValue(0);
|
62
|
-
const updateRightElementWidth = useCallback(() => {
|
63
|
-
'worklet';
|
64
|
-
|
65
|
-
if (rightOffset.value === null) {
|
66
|
-
rightOffset.value = rowWidth.value;
|
67
|
-
}
|
68
|
-
|
69
|
-
rightWidth.value = Math.max(0, rowWidth.value - rightOffset.value);
|
70
|
-
}, [rightOffset, rightWidth, rowWidth]);
|
71
60
|
const updateAnimatedEvent = useCallback(() => {
|
72
61
|
'worklet';
|
73
62
|
|
@@ -105,11 +94,12 @@ const Swipeable = /*#__PURE__*/forwardRef(function Swipeable(props, ref) {
|
|
105
94
|
'worklet';
|
106
95
|
|
107
96
|
const translationSpringConfig = {
|
108
|
-
|
109
|
-
|
110
|
-
stiffness:
|
97
|
+
mass: 2,
|
98
|
+
damping: 1000,
|
99
|
+
stiffness: 700,
|
111
100
|
velocity: velocityX,
|
112
101
|
overshootClamping: true,
|
102
|
+
reduceMotion: ReduceMotion.System,
|
113
103
|
...animationOptions
|
114
104
|
};
|
115
105
|
const isClosing = toValue === 0;
|
@@ -126,31 +116,68 @@ const Swipeable = /*#__PURE__*/forwardRef(function Swipeable(props, ref) {
|
|
126
116
|
dispatchEndEvents(frozenRowState, toValue);
|
127
117
|
}
|
128
118
|
});
|
129
|
-
const progressTarget = toValue === 0 ? 0 : 1;
|
130
|
-
showLeftProgress.value =
|
131
|
-
showRightProgress.value =
|
119
|
+
const progressTarget = toValue === 0 ? 0 : 1 * Math.sign(toValue);
|
120
|
+
showLeftProgress.value = withSpring(Math.max(progressTarget, 0), progressSpringConfig);
|
121
|
+
showRightProgress.value = withSpring(Math.max(-progressTarget, 0), progressSpringConfig);
|
132
122
|
dispatchImmediateEvents(frozenRowState, toValue);
|
133
123
|
rowState.value = Math.sign(toValue);
|
134
124
|
}, [rowState, animationOptions, appliedTranslation, showLeftProgress, leftWidth, showRightProgress, rightWidth, dispatchImmediateEvents, dispatchEndEvents]);
|
125
|
+
const leftLayoutRef = useAnimatedRef();
|
126
|
+
const leftWrapperLayoutRef = useAnimatedRef();
|
127
|
+
const rightLayoutRef = useAnimatedRef();
|
128
|
+
const updateElementWidths = useCallback(() => {
|
129
|
+
'worklet';
|
130
|
+
|
131
|
+
var _leftLayout$pageX, _leftWrapperLayout$pa, _rightLayout$pageX, _leftWrapperLayout$pa2;
|
132
|
+
|
133
|
+
const leftLayout = measure(leftLayoutRef);
|
134
|
+
const leftWrapperLayout = measure(leftWrapperLayoutRef);
|
135
|
+
const rightLayout = measure(rightLayoutRef);
|
136
|
+
leftWidth.value = ((_leftLayout$pageX = leftLayout === null || leftLayout === void 0 ? void 0 : leftLayout.pageX) !== null && _leftLayout$pageX !== void 0 ? _leftLayout$pageX : 0) - ((_leftWrapperLayout$pa = leftWrapperLayout === null || leftWrapperLayout === void 0 ? void 0 : leftWrapperLayout.pageX) !== null && _leftWrapperLayout$pa !== void 0 ? _leftWrapperLayout$pa : 0);
|
137
|
+
rightWidth.value = rowWidth.value - ((_rightLayout$pageX = rightLayout === null || rightLayout === void 0 ? void 0 : rightLayout.pageX) !== null && _rightLayout$pageX !== void 0 ? _rightLayout$pageX : rowWidth.value) + ((_leftWrapperLayout$pa2 = leftWrapperLayout === null || leftWrapperLayout === void 0 ? void 0 : leftWrapperLayout.pageX) !== null && _leftWrapperLayout$pa2 !== void 0 ? _leftWrapperLayout$pa2 : 0);
|
138
|
+
}, [leftLayoutRef, leftWrapperLayoutRef, rightLayoutRef, leftWidth, rightWidth, rowWidth.value]);
|
135
139
|
const swipeableMethods = useMemo(() => ({
|
136
140
|
close() {
|
137
141
|
'worklet';
|
138
142
|
|
139
|
-
|
143
|
+
if (_WORKLET) {
|
144
|
+
animateRow(0);
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
|
148
|
+
runOnUI(() => {
|
149
|
+
animateRow(0);
|
150
|
+
})();
|
140
151
|
},
|
141
152
|
|
142
153
|
openLeft() {
|
143
154
|
'worklet';
|
144
155
|
|
145
|
-
|
156
|
+
if (_WORKLET) {
|
157
|
+
updateElementWidths();
|
158
|
+
animateRow(leftWidth.value);
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
|
162
|
+
runOnUI(() => {
|
163
|
+
updateElementWidths();
|
164
|
+
animateRow(leftWidth.value);
|
165
|
+
})();
|
146
166
|
},
|
147
167
|
|
148
168
|
openRight() {
|
149
|
-
'worklet';
|
169
|
+
'worklet';
|
150
170
|
|
151
|
-
|
171
|
+
if (_WORKLET) {
|
172
|
+
updateElementWidths();
|
173
|
+
animateRow(-rightWidth.value);
|
174
|
+
return;
|
175
|
+
}
|
152
176
|
|
153
|
-
|
177
|
+
runOnUI(() => {
|
178
|
+
updateElementWidths();
|
179
|
+
animateRow(-rightWidth.value);
|
180
|
+
})();
|
154
181
|
},
|
155
182
|
|
156
183
|
reset() {
|
@@ -162,28 +189,35 @@ const Swipeable = /*#__PURE__*/forwardRef(function Swipeable(props, ref) {
|
|
162
189
|
rowState.value = 0;
|
163
190
|
}
|
164
191
|
|
165
|
-
}), [
|
192
|
+
}), [animateRow, updateElementWidths, leftWidth, rightWidth, userDrag, showLeftProgress, appliedTranslation, rowState]);
|
166
193
|
const onRowLayout = useCallback(({
|
167
194
|
nativeEvent
|
168
195
|
}) => {
|
169
196
|
rowWidth.value = nativeEvent.layout.width;
|
170
|
-
}, [rowWidth]);
|
197
|
+
}, [rowWidth]); // As stated in `Dimensions.get` docstring, this function should be called on every render
|
198
|
+
// since dimensions may change (e.g. orientation change)
|
199
|
+
|
200
|
+
const leftActionAnimation = useAnimatedStyle(() => {
|
201
|
+
return {
|
202
|
+
opacity: showLeftProgress.value === 0 ? 0 : 1
|
203
|
+
};
|
204
|
+
});
|
171
205
|
const leftElement = useCallback(() => /*#__PURE__*/React.createElement(Animated.View, {
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
206
|
+
ref: leftWrapperLayoutRef,
|
207
|
+
style: [styles.leftActions, leftActionAnimation]
|
208
|
+
}, renderLeftActions === null || renderLeftActions === void 0 ? void 0 : renderLeftActions(showLeftProgress, appliedTranslation, swipeableMethods), /*#__PURE__*/React.createElement(Animated.View, {
|
209
|
+
ref: leftLayoutRef
|
210
|
+
})), [appliedTranslation, leftActionAnimation, leftLayoutRef, leftWrapperLayoutRef, renderLeftActions, showLeftProgress, swipeableMethods]);
|
211
|
+
const rightActionAnimation = useAnimatedStyle(() => {
|
212
|
+
return {
|
213
|
+
opacity: showRightProgress.value === 0 ? 0 : 1
|
214
|
+
};
|
215
|
+
});
|
178
216
|
const rightElement = useCallback(() => /*#__PURE__*/React.createElement(Animated.View, {
|
179
|
-
style: [styles.rightActions]
|
180
|
-
}, renderRightActions === null || renderRightActions === void 0 ? void 0 : renderRightActions(showRightProgress, appliedTranslation, swipeableMethods), /*#__PURE__*/React.createElement(View, {
|
181
|
-
|
182
|
-
|
183
|
-
}) => {
|
184
|
-
rightOffset.value = nativeEvent.layout.x;
|
185
|
-
}
|
186
|
-
})), [appliedTranslation, renderRightActions, rightOffset, showRightProgress, swipeableMethods]);
|
217
|
+
style: [styles.rightActions, rightActionAnimation]
|
218
|
+
}, renderRightActions === null || renderRightActions === void 0 ? void 0 : renderRightActions(showRightProgress, appliedTranslation, swipeableMethods), /*#__PURE__*/React.createElement(Animated.View, {
|
219
|
+
ref: rightLayoutRef
|
220
|
+
})), [appliedTranslation, renderRightActions, rightActionAnimation, rightLayoutRef, showRightProgress, swipeableMethods]);
|
187
221
|
const handleRelease = useCallback(event => {
|
188
222
|
'worklet';
|
189
223
|
|
@@ -191,7 +225,6 @@ const Swipeable = /*#__PURE__*/forwardRef(function Swipeable(props, ref) {
|
|
191
225
|
velocityX
|
192
226
|
} = event;
|
193
227
|
userDrag.value = event.translationX;
|
194
|
-
updateRightElementWidth();
|
195
228
|
const leftThresholdProp = leftThreshold !== null && leftThreshold !== void 0 ? leftThreshold : leftWidth.value / 2;
|
196
229
|
const rightThresholdProp = rightThreshold !== null && rightThreshold !== void 0 ? rightThreshold : rightWidth.value / 2;
|
197
230
|
const translationX = (userDrag.value + DRAG_TOSS * velocityX) / friction;
|
@@ -216,7 +249,7 @@ const Swipeable = /*#__PURE__*/forwardRef(function Swipeable(props, ref) {
|
|
216
249
|
}
|
217
250
|
|
218
251
|
animateRow(toValue, velocityX / friction);
|
219
|
-
}, [animateRow, friction, leftThreshold, leftWidth, rightThreshold, rightWidth, rowState, userDrag
|
252
|
+
}, [animateRow, friction, leftThreshold, leftWidth, rightThreshold, rightWidth, rowState, userDrag]);
|
220
253
|
const close = useCallback(() => {
|
221
254
|
'worklet';
|
222
255
|
|
@@ -228,9 +261,7 @@ const Swipeable = /*#__PURE__*/forwardRef(function Swipeable(props, ref) {
|
|
228
261
|
close();
|
229
262
|
}
|
230
263
|
}), [close, rowState]);
|
231
|
-
const panGesture = useMemo(() => Gesture.Pan().enabled(enabled !== false).enableTrackpadTwoFingerGesture(enableTrackpadTwoFingerGesture).activeOffsetX([-dragOffsetFromRightEdge, dragOffsetFromLeftEdge]).onStart((
|
232
|
-
updateRightElementWidth();
|
233
|
-
}).onUpdate(event => {
|
264
|
+
const panGesture = useMemo(() => Gesture.Pan().enabled(enabled !== false).enableTrackpadTwoFingerGesture(enableTrackpadTwoFingerGesture).activeOffsetX([-dragOffsetFromRightEdge, dragOffsetFromLeftEdge]).onStart(updateElementWidths).onUpdate(event => {
|
234
265
|
userDrag.value = event.translationX;
|
235
266
|
const direction = rowState.value === -1 ? SwipeDirection.RIGHT : rowState.value === 1 ? SwipeDirection.LEFT : event.translationX > 0 ? SwipeDirection.RIGHT : SwipeDirection.LEFT;
|
236
267
|
|
@@ -249,7 +280,7 @@ const Swipeable = /*#__PURE__*/forwardRef(function Swipeable(props, ref) {
|
|
249
280
|
handleRelease(event);
|
250
281
|
}).onFinalize(() => {
|
251
282
|
dragStarted.value = false;
|
252
|
-
}), [dragOffsetFromLeftEdge, dragOffsetFromRightEdge, dragStarted, enableTrackpadTwoFingerGesture, enabled, handleRelease, onSwipeableCloseStartDrag, onSwipeableOpenStartDrag, rowState, updateAnimatedEvent,
|
283
|
+
}), [dragOffsetFromLeftEdge, dragOffsetFromRightEdge, dragStarted, enableTrackpadTwoFingerGesture, enabled, handleRelease, onSwipeableCloseStartDrag, onSwipeableOpenStartDrag, rowState, updateAnimatedEvent, updateElementWidths, userDrag]);
|
253
284
|
useImperativeHandle(ref, () => swipeableMethods, [swipeableMethods]);
|
254
285
|
const animatedStyle = useAnimatedStyle(() => ({
|
255
286
|
transform: [{
|
@@ -279,10 +310,12 @@ const styles = StyleSheet.create({
|
|
279
310
|
overflow: 'hidden'
|
280
311
|
},
|
281
312
|
leftActions: { ...StyleSheet.absoluteFillObject,
|
282
|
-
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row'
|
313
|
+
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
|
314
|
+
overflow: 'hidden'
|
283
315
|
},
|
284
316
|
rightActions: { ...StyleSheet.absoluteFillObject,
|
285
|
-
flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse'
|
317
|
+
flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',
|
318
|
+
overflow: 'hidden'
|
286
319
|
}
|
287
320
|
});
|
288
321
|
//# sourceMappingURL=ReanimatedSwipeable.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["ReanimatedSwipeable.tsx"],"names":["React","forwardRef","useCallback","useImperativeHandle","useMemo","GestureObjects","Gesture","GestureDetector","Animated","interpolate","runOnJS","useAnimatedStyle","useSharedValue","withSpring","I18nManager","StyleSheet","View","DRAG_TOSS","SwipeDirection","Swipeable","props","ref","defaultProps","friction","overshootFriction","dragOffset","enableTrackpadTwoFingerGesture","leftThreshold","rightThreshold","enabled","containerStyle","childrenContainerStyle","animationOptions","overshootLeft","overshootRight","testID","children","dragOffsetFromLeftEdge","dragOffsetFromRightEdge","onSwipeableOpenStartDrag","onSwipeableCloseStartDrag","onSwipeableWillOpen","onSwipeableWillClose","onSwipeableOpen","onSwipeableClose","renderLeftActions","renderRightActions","remainingProps","rowState","userDrag","appliedTranslation","rowWidth","leftWidth","rightWidth","rightOffset","showLeftProgress","showRightProgress","updateRightElementWidth","value","Math","max","updateAnimatedEvent","shouldOvershootLeft","shouldOvershootRight","startOffset","offsetDrag","dispatchImmediateEvents","fromValue","toValue","RIGHT","LEFT","dispatchEndEvents","animateRow","velocityX","translationSpringConfig","duration","dampingRatio","stiffness","velocity","overshootClamping","isClosing","moveToRight","usedWidth","progressSpringConfig","restDisplacementThreshold","restSpeedThreshold","frozenRowState","isFinished","progressTarget","sign","swipeableMethods","close","openLeft","openRight","reset","onRowLayout","nativeEvent","layout","width","leftElement","styles","leftActions","x","rightElement","rightActions","handleRelease","event","translationX","leftThresholdProp","rightThresholdProp","dragStarted","tapGesture","Tap","shouldCancelWhenOutside","onStart","panGesture","Pan","activeOffsetX","onUpdate","direction","onEnd","onFinalize","animatedStyle","transform","translateX","pointerEvents","swipeableComponent","container","create","overflow","absoluteFillObject","flexDirection","isRTL"],"mappings":";;AAAA;AACA;AACA;AAEA,OAAOA,KAAP,IAEEC,UAFF,EAGEC,WAHF,EAIEC,mBAJF,EAKEC,OALF,QAMO,OANP;AAOA,SAASC,cAAc,IAAIC,OAA3B,QAA0C,qCAA1C;AACA,SAASC,eAAT,QAAgC,sCAAhC;AAOA,OAAOC,QAAP,IAEEC,WAFF,EAGEC,OAHF,EAIEC,gBAJF,EAKEC,cALF,EAMEC,UANF,QAOO,yBAPP;AAQA,SACEC,WADF,EAIEC,UAJF,EAKEC,IALF,QAOO,cAPP;AASA,MAAMC,SAAS,GAAG,IAAlB;IAOKC,c;;WAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;GAAAA,c,KAAAA,c;;AAsKL,MAAMC,SAAS,gBAAGlB,UAAU,CAC1B,SAASkB,SAAT,CACEC,KADF,EAEEC,GAFF,EAGE;AACA,QAAMC,YAAY,GAAG;AACnBC,IAAAA,QAAQ,EAAE,CADS;AAEnBC,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B3F,sBAAhB;AAAtB,KACGK,QADH,CADF,CANF,CADF,CADF;AAiBA,SAAOD,MAAM,gBACX,oBAAC,IAAD;AAAM,IAAA,MAAM,EAAEA;AAAd,KAAuB2F,kBAAvB,CADW,GAGXA,kBAHF;AAKD,CAheyB,CAA5B;AAmeA,eAAe3G,SAAf;AAGA,MAAMiF,MAAM,GAAGrF,UAAU,CAACiH,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AACTE,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/B5B,EAAAA,WAAW,EAAE,EACX,GAAGtF,UAAU,CAACmH,kBADH;AAEXC,IAAAA,aAAa,EAAErH,WAAW,CAACsH,KAAZ,GAAoB,aAApB,GAAoC;AAFxC,GAJkB;AAQ/B5B,EAAAA,YAAY,EAAE,EACZ,GAAGzF,UAAU,CAACmH,kBADF;AAEZC,IAAAA,aAAa,EAAErH,WAAW,CAACsH,KAAZ,GAAoB,KAApB,GAA4B;AAF/B;AARiB,CAAlB,CAAf","sourcesContent":["// Similarily to the DrawerLayout component this deserves to be put in a\n// separate repo. Although, keeping it here for the time being will allow us to\n// move faster and fix possible issues quicker\n\nimport React, {\n ForwardedRef,\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n} from 'react';\nimport { GestureObjects as Gesture } from '../handlers/gestures/gestureObjects';\nimport { GestureDetector } from '../handlers/gestures/GestureDetector';\nimport {\n GestureStateChangeEvent,\n GestureUpdateEvent,\n} from '../handlers/gestureHandlerCommon';\nimport type { PanGestureHandlerProps } from '../handlers/PanGestureHandler';\nimport type { PanGestureHandlerEventPayload } from '../handlers/GestureHandlerEventPayload';\nimport Animated, {\n SharedValue,\n interpolate,\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withSpring,\n} from 'react-native-reanimated';\nimport {\n I18nManager,\n LayoutChangeEvent,\n StyleProp,\n StyleSheet,\n View,\n ViewStyle,\n} from 'react-native';\n\nconst DRAG_TOSS = 0.05;\n\ntype SwipeableExcludes = Exclude<\n keyof PanGestureHandlerProps,\n 'onGestureEvent' | 'onHandlerStateChange'\n>;\n\nenum SwipeDirection {\n LEFT = 'left',\n RIGHT = 'right',\n}\n\nexport interface SwipeableProps\n extends Pick<PanGestureHandlerProps, SwipeableExcludes> {\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance. e.g. value of 1 will indicate that the swipeable panel\n * should exactly follow the gesture, 2 means it is going to be two times\n * \"slower\".\n */\n friction?: number;\n\n /**\n * Distance from the left edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n leftThreshold?: number;\n\n /**\n * Distance from the right edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n rightThreshold?: number;\n\n /**\n * Distance that the panel must be dragged from the left edge to be considered\n * a swipe. The default value is 10.\n */\n dragOffsetFromLeftEdge?: number;\n\n /**\n * Distance that the panel must be dragged from the right edge to be considered\n * a swipe. The default value is 10.\n */\n dragOffsetFromRightEdge?: number;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the left\n * actions panel's width. It is set to true by default as long as the left\n * panel render method is present.\n */\n overshootLeft?: boolean;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the\n * right actions panel's width. It is set to true by default as long as the\n * right panel render method is present.\n */\n overshootRight?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance at overshoot. Default value is 1, it mean no friction, for\n * a native feel, try 8 or above.\n */\n overshootFriction?: number;\n\n /**\n * Called when action panel gets open (either right or left).\n */\n onSwipeableOpen?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel is closed.\n */\n onSwipeableClose?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel starts animating on open (either right or left).\n */\n onSwipeableWillOpen?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel starts animating on close.\n */\n onSwipeableWillClose?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel starts being shown on dragging to open.\n */\n onSwipeableOpenStartDrag?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel starts being shown on dragging to close.\n */\n onSwipeableCloseStartDrag?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * `progress`: Equals `0` when `swipeable` is closed, `1` when `swipeable` is opened.\n * - When the element overshoots it's opened position the value tends towards `Infinity`.\n * - Goes back to `1` when `swipeable` is released.\n *\n * `translation`: a horizontal offset of the `swipeable` relative to its closed position.\\\n * `swipeableMethods`: provides an object exposing methods for controlling the `swipeable`.\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderLeftActions?: (\n progress: SharedValue<number>,\n translation: SharedValue<number>,\n swipeableMethods: SwipeableMethods\n ) => React.ReactNode;\n\n /**\n * `progress`: Equals `0` when `swipeable` is closed, `1` when `swipeable` is opened.\n * - When the element overshoots it's opened position the value tends towards `Infinity`.\n * - Goes back to `1` when `swipeable` is released.\n *\n * `translation`: a horizontal offset of the `swipeable` relative to its closed position.\\\n * `swipeableMethods`: provides an object exposing methods for controlling the `swipeable`.\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderRightActions?: (\n progress: SharedValue<number>,\n translation: SharedValue<number>,\n swipeableMethods: SwipeableMethods\n ) => React.ReactNode;\n\n animationOptions?: Record<string, unknown>;\n\n /**\n * Style object for the container (`Animated.View`), for example to override\n * `overflow: 'hidden'`.\n */\n containerStyle?: StyleProp<ViewStyle>;\n\n /**\n * Style object for the children container (`Animated.View`), for example to\n * apply `flex: 1`\n */\n childrenContainerStyle?: StyleProp<ViewStyle>;\n}\n\nexport interface SwipeableMethods {\n close: () => void;\n openLeft: () => void;\n openRight: () => void;\n reset: () => void;\n}\n\nconst Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(\n function Swipeable(\n props: SwipeableProps,\n ref: ForwardedRef<SwipeableMethods>\n ) {\n const defaultProps = {\n friction: 1,\n overshootFriction: 1,\n dragOffset: 10,\n enableTrackpadTwoFingerGesture: false,\n };\n\n const {\n leftThreshold,\n rightThreshold,\n enabled,\n containerStyle,\n childrenContainerStyle,\n animationOptions,\n overshootLeft,\n overshootRight,\n testID,\n children,\n enableTrackpadTwoFingerGesture = defaultProps.enableTrackpadTwoFingerGesture,\n dragOffsetFromLeftEdge = defaultProps.dragOffset,\n dragOffsetFromRightEdge = defaultProps.dragOffset,\n friction = defaultProps.friction,\n overshootFriction = defaultProps.overshootFriction,\n onSwipeableOpenStartDrag,\n onSwipeableCloseStartDrag,\n onSwipeableWillOpen,\n onSwipeableWillClose,\n onSwipeableOpen,\n onSwipeableClose,\n renderLeftActions,\n renderRightActions,\n ...remainingProps\n } = props;\n\n const rowState = useSharedValue<number>(0);\n\n const userDrag = useSharedValue<number>(0);\n\n const appliedTranslation = useSharedValue<number>(0);\n\n const rowWidth = useSharedValue<number>(0);\n const leftWidth = useSharedValue<number>(0);\n const rightWidth = useSharedValue<number>(0);\n\n // used for synchronizing layout measurements between JS and UI\n const rightOffset = useSharedValue<number | null>(null);\n\n const showLeftProgress = useSharedValue<number>(0);\n const showRightProgress = useSharedValue<number>(0);\n\n const updateRightElementWidth = useCallback(() => {\n 'worklet';\n if (rightOffset.value === null) {\n rightOffset.value = rowWidth.value;\n }\n rightWidth.value = Math.max(0, rowWidth.value - rightOffset.value);\n }, [rightOffset, rightWidth, rowWidth]);\n\n const updateAnimatedEvent = useCallback(() => {\n 'worklet';\n\n const shouldOvershootLeft = overshootLeft ?? leftWidth.value > 0;\n const shouldOvershootRight = overshootRight ?? rightWidth.value > 0;\n\n const startOffset =\n rowState.value === 1\n ? leftWidth.value\n : rowState.value === -1\n ? -rightWidth.value\n : 0;\n\n const offsetDrag = userDrag.value / friction + startOffset;\n\n appliedTranslation.value = interpolate(\n offsetDrag,\n [\n -rightWidth.value - 1,\n -rightWidth.value,\n leftWidth.value,\n leftWidth.value + 1,\n ],\n [\n -rightWidth.value -\n (shouldOvershootRight ? 1 / overshootFriction : 0),\n -rightWidth.value,\n leftWidth.value,\n leftWidth.value + (shouldOvershootLeft ? 1 / overshootFriction : 0),\n ]\n );\n\n showLeftProgress.value =\n leftWidth.value > 0\n ? interpolate(\n appliedTranslation.value,\n [-1, 0, leftWidth.value],\n [0, 0, 1]\n )\n : 0;\n\n showRightProgress.value =\n rightWidth.value > 0\n ? interpolate(\n appliedTranslation.value,\n [-rightWidth.value, 0, 1],\n [1, 0, 0]\n )\n : 0;\n }, [\n appliedTranslation,\n friction,\n leftWidth,\n overshootFriction,\n rightWidth,\n rowState,\n showLeftProgress,\n showRightProgress,\n userDrag,\n overshootLeft,\n overshootRight,\n ]);\n\n const dispatchImmediateEvents = useCallback(\n (fromValue: number, toValue: number) => {\n 'worklet';\n if (toValue > 0 && onSwipeableWillOpen) {\n runOnJS(onSwipeableWillOpen)(SwipeDirection.RIGHT);\n } else if (toValue < 0 && onSwipeableWillOpen) {\n runOnJS(onSwipeableWillOpen)(SwipeDirection.LEFT);\n } else if (onSwipeableWillClose) {\n runOnJS(onSwipeableWillClose)(\n fromValue > 0 ? SwipeDirection.LEFT : SwipeDirection.RIGHT\n );\n }\n },\n [onSwipeableWillClose, onSwipeableWillOpen]\n );\n\n const dispatchEndEvents = useCallback(\n (fromValue: number, toValue: number) => {\n 'worklet';\n if (toValue > 0 && onSwipeableOpen) {\n runOnJS(onSwipeableOpen)(SwipeDirection.RIGHT);\n } else if (toValue < 0 && onSwipeableOpen) {\n runOnJS(onSwipeableOpen)(SwipeDirection.LEFT);\n } else if (onSwipeableClose) {\n runOnJS(onSwipeableClose)(\n fromValue > 0 ? SwipeDirection.LEFT : SwipeDirection.RIGHT\n );\n }\n },\n [onSwipeableClose, onSwipeableOpen]\n );\n\n const animateRow: (toValue: number, velocityX?: number) => void =\n useCallback(\n (toValue: number, velocityX?: number) => {\n 'worklet';\n\n const translationSpringConfig = {\n duration: 1000,\n dampingRatio: 0.9,\n stiffness: 500,\n velocity: velocityX,\n overshootClamping: true,\n ...animationOptions,\n };\n\n const isClosing = toValue === 0;\n const moveToRight = isClosing ? rowState.value < 0 : toValue > 0;\n\n const usedWidth = isClosing\n ? moveToRight\n ? rightWidth.value\n : leftWidth.value\n : moveToRight\n ? leftWidth.value\n : rightWidth.value;\n\n const progressSpringConfig = {\n ...translationSpringConfig,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 0.01,\n velocity:\n velocityX &&\n interpolate(velocityX, [-usedWidth, usedWidth], [-1, 1]),\n };\n\n const frozenRowState = rowState.value;\n\n appliedTranslation.value = withSpring(\n toValue,\n translationSpringConfig,\n (isFinished) => {\n if (isFinished) {\n dispatchEndEvents(frozenRowState, toValue);\n }\n }\n );\n\n const progressTarget = toValue === 0 ? 0 : 1;\n\n showLeftProgress.value =\n leftWidth.value > 0\n ? withSpring(progressTarget, progressSpringConfig)\n : 0;\n showRightProgress.value =\n rightWidth.value > 0\n ? withSpring(progressTarget, progressSpringConfig)\n : 0;\n\n dispatchImmediateEvents(frozenRowState, toValue);\n\n rowState.value = Math.sign(toValue);\n },\n [\n rowState,\n animationOptions,\n appliedTranslation,\n showLeftProgress,\n leftWidth,\n showRightProgress,\n rightWidth,\n dispatchImmediateEvents,\n dispatchEndEvents,\n ]\n );\n\n const swipeableMethods = useMemo<SwipeableMethods>(\n () => ({\n close() {\n 'worklet';\n animateRow(0);\n },\n openLeft() {\n 'worklet';\n animateRow(leftWidth.value);\n },\n openRight() {\n 'worklet';\n // rightOffset and rowWidth are already much sooner than rightWidth\n animateRow((rightOffset.value ?? 0) - rowWidth.value);\n },\n reset() {\n 'worklet';\n userDrag.value = 0;\n showLeftProgress.value = 0;\n appliedTranslation.value = 0;\n rowState.value = 0;\n },\n }),\n [\n leftWidth,\n rightOffset,\n rowWidth,\n userDrag,\n showLeftProgress,\n appliedTranslation,\n rowState,\n animateRow,\n ]\n );\n\n const onRowLayout = useCallback(\n ({ nativeEvent }: LayoutChangeEvent) => {\n rowWidth.value = nativeEvent.layout.width;\n },\n [rowWidth]\n );\n\n const leftElement = useCallback(\n () => (\n <Animated.View style={[styles.leftActions]}>\n {renderLeftActions?.(\n showLeftProgress,\n appliedTranslation,\n swipeableMethods\n )}\n <View\n onLayout={({ nativeEvent }) =>\n (leftWidth.value = nativeEvent.layout.x)\n }\n />\n </Animated.View>\n ),\n [\n appliedTranslation,\n leftWidth,\n renderLeftActions,\n showLeftProgress,\n swipeableMethods,\n ]\n );\n\n const rightElement = useCallback(\n () => (\n <Animated.View style={[styles.rightActions]}>\n {renderRightActions?.(\n showRightProgress,\n appliedTranslation,\n swipeableMethods\n )}\n <View\n onLayout={({ nativeEvent }) => {\n rightOffset.value = nativeEvent.layout.x;\n }}\n />\n </Animated.View>\n ),\n [\n appliedTranslation,\n renderRightActions,\n rightOffset,\n showRightProgress,\n swipeableMethods,\n ]\n );\n\n const handleRelease = useCallback(\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\n 'worklet';\n const { velocityX } = event;\n userDrag.value = event.translationX;\n\n updateRightElementWidth();\n\n const leftThresholdProp = leftThreshold ?? leftWidth.value / 2;\n const rightThresholdProp = rightThreshold ?? rightWidth.value / 2;\n\n const translationX =\n (userDrag.value + DRAG_TOSS * velocityX) / friction;\n\n let toValue = 0;\n\n if (rowState.value === 0) {\n if (translationX > leftThresholdProp) {\n toValue = leftWidth.value;\n } else if (translationX < -rightThresholdProp) {\n toValue = -rightWidth.value;\n }\n } else if (rowState.value === 1) {\n // Swiped to left\n if (translationX > -leftThresholdProp) {\n toValue = leftWidth.value;\n }\n } else {\n // Swiped to right\n if (translationX < rightThresholdProp) {\n toValue = -rightWidth.value;\n }\n }\n\n animateRow(toValue, velocityX / friction);\n },\n [\n animateRow,\n friction,\n leftThreshold,\n leftWidth,\n rightThreshold,\n rightWidth,\n rowState,\n userDrag,\n updateRightElementWidth,\n ]\n );\n\n const close = useCallback(() => {\n 'worklet';\n animateRow(0);\n }, [animateRow]);\n\n const dragStarted = useSharedValue<boolean>(false);\n\n const tapGesture = useMemo(\n () =>\n Gesture.Tap()\n .shouldCancelWhenOutside(true)\n .onStart(() => {\n if (rowState.value !== 0) {\n close();\n }\n }),\n [close, rowState]\n );\n\n const panGesture = useMemo(\n () =>\n Gesture.Pan()\n .enabled(enabled !== false)\n .enableTrackpadTwoFingerGesture(enableTrackpadTwoFingerGesture)\n .activeOffsetX([-dragOffsetFromRightEdge, dragOffsetFromLeftEdge])\n .onStart(() => {\n updateRightElementWidth();\n })\n .onUpdate(\n (event: GestureUpdateEvent<PanGestureHandlerEventPayload>) => {\n userDrag.value = event.translationX;\n\n const direction =\n rowState.value === -1\n ? SwipeDirection.RIGHT\n : rowState.value === 1\n ? SwipeDirection.LEFT\n : event.translationX > 0\n ? SwipeDirection.RIGHT\n : SwipeDirection.LEFT;\n\n if (!dragStarted.value) {\n dragStarted.value = true;\n if (rowState.value === 0 && onSwipeableOpenStartDrag) {\n runOnJS(onSwipeableOpenStartDrag)(direction);\n } else if (onSwipeableCloseStartDrag) {\n runOnJS(onSwipeableCloseStartDrag)(direction);\n }\n }\n\n updateAnimatedEvent();\n }\n )\n .onEnd(\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\n handleRelease(event);\n }\n )\n .onFinalize(() => {\n dragStarted.value = false;\n }),\n [\n dragOffsetFromLeftEdge,\n dragOffsetFromRightEdge,\n dragStarted,\n enableTrackpadTwoFingerGesture,\n enabled,\n handleRelease,\n onSwipeableCloseStartDrag,\n onSwipeableOpenStartDrag,\n rowState,\n updateAnimatedEvent,\n updateRightElementWidth,\n userDrag,\n ]\n );\n\n useImperativeHandle(ref, () => swipeableMethods, [swipeableMethods]);\n\n const animatedStyle = useAnimatedStyle(\n () => ({\n transform: [{ translateX: appliedTranslation.value }],\n pointerEvents: rowState.value === 0 ? 'auto' : 'box-only',\n }),\n [appliedTranslation, rowState]\n );\n\n const swipeableComponent = (\n <GestureDetector gesture={panGesture} touchAction=\"pan-y\">\n <Animated.View\n {...remainingProps}\n onLayout={onRowLayout}\n style={[styles.container, containerStyle]}>\n {leftElement()}\n {rightElement()}\n <GestureDetector gesture={tapGesture} touchAction=\"pan-y\">\n <Animated.View style={[animatedStyle, childrenContainerStyle]}>\n {children}\n </Animated.View>\n </GestureDetector>\n </Animated.View>\n </GestureDetector>\n );\n\n return testID ? (\n <View testID={testID}>{swipeableComponent}</View>\n ) : (\n swipeableComponent\n );\n }\n);\n\nexport default Swipeable;\nexport type SwipeableRef = ForwardedRef<SwipeableMethods>;\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n leftActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',\n },\n rightActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',\n },\n});\n"]}
|
1
|
+
{"version":3,"sources":["ReanimatedSwipeable.tsx"],"names":["React","forwardRef","useCallback","useImperativeHandle","useMemo","GestureObjects","Gesture","GestureDetector","Animated","ReduceMotion","interpolate","measure","runOnJS","runOnUI","useAnimatedRef","useAnimatedStyle","useSharedValue","withSpring","I18nManager","StyleSheet","View","DRAG_TOSS","SwipeDirection","Swipeable","props","ref","defaultProps","friction","overshootFriction","dragOffset","enableTrackpadTwoFingerGesture","leftThreshold","rightThreshold","enabled","containerStyle","childrenContainerStyle","animationOptions","overshootLeft","overshootRight","testID","children","dragOffsetFromLeftEdge","dragOffsetFromRightEdge","onSwipeableOpenStartDrag","onSwipeableCloseStartDrag","onSwipeableWillOpen","onSwipeableWillClose","onSwipeableOpen","onSwipeableClose","renderLeftActions","renderRightActions","remainingProps","rowState","userDrag","appliedTranslation","rowWidth","leftWidth","rightWidth","showLeftProgress","showRightProgress","updateAnimatedEvent","shouldOvershootLeft","value","shouldOvershootRight","startOffset","offsetDrag","dispatchImmediateEvents","fromValue","toValue","RIGHT","LEFT","dispatchEndEvents","animateRow","velocityX","translationSpringConfig","mass","damping","stiffness","velocity","overshootClamping","reduceMotion","System","isClosing","moveToRight","usedWidth","progressSpringConfig","restDisplacementThreshold","restSpeedThreshold","frozenRowState","isFinished","progressTarget","Math","sign","max","leftLayoutRef","leftWrapperLayoutRef","rightLayoutRef","updateElementWidths","leftLayout","leftWrapperLayout","rightLayout","pageX","swipeableMethods","close","_WORKLET","openLeft","openRight","reset","onRowLayout","nativeEvent","layout","width","leftActionAnimation","opacity","leftElement","styles","leftActions","rightActionAnimation","rightElement","rightActions","handleRelease","event","translationX","leftThresholdProp","rightThresholdProp","dragStarted","tapGesture","Tap","shouldCancelWhenOutside","onStart","panGesture","Pan","activeOffsetX","onUpdate","direction","onEnd","onFinalize","animatedStyle","transform","translateX","pointerEvents","swipeableComponent","container","create","overflow","absoluteFillObject","flexDirection","isRTL"],"mappings":";;AAAA;AACA;AACA;AAEA,OAAOA,KAAP,IAEEC,UAFF,EAGEC,WAHF,EAIEC,mBAJF,EAKEC,OALF,QAMO,OANP;AAOA,SAASC,cAAc,IAAIC,OAA3B,QAA0C,qCAA1C;AACA,SAASC,eAAT,QAAgC,sCAAhC;AAOA,OAAOC,QAAP,IACEC,YADF,EAGEC,WAHF,EAIEC,OAJF,EAKEC,OALF,EAMEC,OANF,EAOEC,cAPF,EAQEC,gBARF,EASEC,cATF,EAUEC,UAVF,QAWO,yBAXP;AAYA,SACEC,WADF,EAIEC,UAJF,EAKEC,IALF,QAOO,cAPP;AASA,MAAMC,SAAS,GAAG,IAAlB;IAOKC,c;;WAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;GAAAA,c,KAAAA,c;;AAsKL,MAAMC,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B;AAAsC,IAAA,WAAW,EAAC;AAAlD,kBACE,oBAAC,QAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAE,CAACW,aAAD,EAAgBtG,sBAAhB;AAAtB,KACGK,QADH,CADF,CANF,CADF,CADF;AAiBA,SAAOD,MAAM,gBACX,oBAAC,IAAD;AAAM,IAAA,MAAM,EAAEA;AAAd,KAAuBsG,kBAAvB,CADW,GAGXA,kBAHF;AAKD,CA5gByB,CAA5B;AA+gBA,eAAetH,SAAf;AAGA,MAAM4F,MAAM,GAAGhG,UAAU,CAAC4H,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AACTE,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/B5B,EAAAA,WAAW,EAAE,EACX,GAAGjG,UAAU,CAAC8H,kBADH;AAEXC,IAAAA,aAAa,EAAEhI,WAAW,CAACiI,KAAZ,GAAoB,aAApB,GAAoC,KAFxC;AAGXH,IAAAA,QAAQ,EAAE;AAHC,GAJkB;AAS/BzB,EAAAA,YAAY,EAAE,EACZ,GAAGpG,UAAU,CAAC8H,kBADF;AAEZC,IAAAA,aAAa,EAAEhI,WAAW,CAACiI,KAAZ,GAAoB,KAApB,GAA4B,aAF/B;AAGZH,IAAAA,QAAQ,EAAE;AAHE;AATiB,CAAlB,CAAf","sourcesContent":["// Similarily to the DrawerLayout component this deserves to be put in a\n// separate repo. Although, keeping it here for the time being will allow us to\n// move faster and fix possible issues quicker\n\nimport React, {\n ForwardedRef,\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n} from 'react';\nimport { GestureObjects as Gesture } from '../handlers/gestures/gestureObjects';\nimport { GestureDetector } from '../handlers/gestures/GestureDetector';\nimport {\n GestureStateChangeEvent,\n GestureUpdateEvent,\n} from '../handlers/gestureHandlerCommon';\nimport type { PanGestureHandlerProps } from '../handlers/PanGestureHandler';\nimport type { PanGestureHandlerEventPayload } from '../handlers/GestureHandlerEventPayload';\nimport Animated, {\n ReduceMotion,\n SharedValue,\n interpolate,\n measure,\n runOnJS,\n runOnUI,\n useAnimatedRef,\n useAnimatedStyle,\n useSharedValue,\n withSpring,\n} from 'react-native-reanimated';\nimport {\n I18nManager,\n LayoutChangeEvent,\n StyleProp,\n StyleSheet,\n View,\n ViewStyle,\n} from 'react-native';\n\nconst DRAG_TOSS = 0.05;\n\ntype SwipeableExcludes = Exclude<\n keyof PanGestureHandlerProps,\n 'onGestureEvent' | 'onHandlerStateChange'\n>;\n\nenum SwipeDirection {\n LEFT = 'left',\n RIGHT = 'right',\n}\n\nexport interface SwipeableProps\n extends Pick<PanGestureHandlerProps, SwipeableExcludes> {\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance. e.g. value of 1 will indicate that the swipeable panel\n * should exactly follow the gesture, 2 means it is going to be two times\n * \"slower\".\n */\n friction?: number;\n\n /**\n * Distance from the left edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n leftThreshold?: number;\n\n /**\n * Distance from the right edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n rightThreshold?: number;\n\n /**\n * Distance that the panel must be dragged from the left edge to be considered\n * a swipe. The default value is 10.\n */\n dragOffsetFromLeftEdge?: number;\n\n /**\n * Distance that the panel must be dragged from the right edge to be considered\n * a swipe. The default value is 10.\n */\n dragOffsetFromRightEdge?: number;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the left\n * actions panel's width. It is set to true by default as long as the left\n * panel render method is present.\n */\n overshootLeft?: boolean;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the\n * right actions panel's width. It is set to true by default as long as the\n * right panel render method is present.\n */\n overshootRight?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance at overshoot. Default value is 1, it mean no friction, for\n * a native feel, try 8 or above.\n */\n overshootFriction?: number;\n\n /**\n * Called when action panel gets open (either right or left).\n */\n onSwipeableOpen?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel is closed.\n */\n onSwipeableClose?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel starts animating on open (either right or left).\n */\n onSwipeableWillOpen?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel starts animating on close.\n */\n onSwipeableWillClose?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel starts being shown on dragging to open.\n */\n onSwipeableOpenStartDrag?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * Called when action panel starts being shown on dragging to close.\n */\n onSwipeableCloseStartDrag?: (\n direction: SwipeDirection.LEFT | SwipeDirection.RIGHT\n ) => void;\n\n /**\n * `progress`: Equals `0` when `swipeable` is closed, `1` when `swipeable` is opened.\n * - When the element overshoots it's opened position the value tends towards `Infinity`.\n * - Goes back to `1` when `swipeable` is released.\n *\n * `translation`: a horizontal offset of the `swipeable` relative to its closed position.\\\n * `swipeableMethods`: provides an object exposing methods for controlling the `swipeable`.\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderLeftActions?: (\n progress: SharedValue<number>,\n translation: SharedValue<number>,\n swipeableMethods: SwipeableMethods\n ) => React.ReactNode;\n\n /**\n * `progress`: Equals `0` when `swipeable` is closed, `1` when `swipeable` is opened.\n * - When the element overshoots it's opened position the value tends towards `Infinity`.\n * - Goes back to `1` when `swipeable` is released.\n *\n * `translation`: a horizontal offset of the `swipeable` relative to its closed position.\\\n * `swipeableMethods`: provides an object exposing methods for controlling the `swipeable`.\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderRightActions?: (\n progress: SharedValue<number>,\n translation: SharedValue<number>,\n swipeableMethods: SwipeableMethods\n ) => React.ReactNode;\n\n animationOptions?: Record<string, unknown>;\n\n /**\n * Style object for the container (`Animated.View`), for example to override\n * `overflow: 'hidden'`.\n */\n containerStyle?: StyleProp<ViewStyle>;\n\n /**\n * Style object for the children container (`Animated.View`), for example to\n * apply `flex: 1`\n */\n childrenContainerStyle?: StyleProp<ViewStyle>;\n}\n\nexport interface SwipeableMethods {\n close: () => void;\n openLeft: () => void;\n openRight: () => void;\n reset: () => void;\n}\n\nconst Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(\n function Swipeable(\n props: SwipeableProps,\n ref: ForwardedRef<SwipeableMethods>\n ) {\n const defaultProps = {\n friction: 1,\n overshootFriction: 1,\n dragOffset: 10,\n enableTrackpadTwoFingerGesture: false,\n };\n\n const {\n leftThreshold,\n rightThreshold,\n enabled,\n containerStyle,\n childrenContainerStyle,\n animationOptions,\n overshootLeft,\n overshootRight,\n testID,\n children,\n enableTrackpadTwoFingerGesture = defaultProps.enableTrackpadTwoFingerGesture,\n dragOffsetFromLeftEdge = defaultProps.dragOffset,\n dragOffsetFromRightEdge = defaultProps.dragOffset,\n friction = defaultProps.friction,\n overshootFriction = defaultProps.overshootFriction,\n onSwipeableOpenStartDrag,\n onSwipeableCloseStartDrag,\n onSwipeableWillOpen,\n onSwipeableWillClose,\n onSwipeableOpen,\n onSwipeableClose,\n renderLeftActions,\n renderRightActions,\n ...remainingProps\n } = props;\n\n const rowState = useSharedValue<number>(0);\n\n const userDrag = useSharedValue<number>(0);\n\n const appliedTranslation = useSharedValue<number>(0);\n\n const rowWidth = useSharedValue<number>(0);\n const leftWidth = useSharedValue<number>(0);\n const rightWidth = useSharedValue<number>(0);\n\n const showLeftProgress = useSharedValue<number>(0);\n const showRightProgress = useSharedValue<number>(0);\n\n const updateAnimatedEvent = useCallback(() => {\n 'worklet';\n\n const shouldOvershootLeft = overshootLeft ?? leftWidth.value > 0;\n const shouldOvershootRight = overshootRight ?? rightWidth.value > 0;\n\n const startOffset =\n rowState.value === 1\n ? leftWidth.value\n : rowState.value === -1\n ? -rightWidth.value\n : 0;\n\n const offsetDrag = userDrag.value / friction + startOffset;\n\n appliedTranslation.value = interpolate(\n offsetDrag,\n [\n -rightWidth.value - 1,\n -rightWidth.value,\n leftWidth.value,\n leftWidth.value + 1,\n ],\n [\n -rightWidth.value -\n (shouldOvershootRight ? 1 / overshootFriction : 0),\n -rightWidth.value,\n leftWidth.value,\n leftWidth.value + (shouldOvershootLeft ? 1 / overshootFriction : 0),\n ]\n );\n\n showLeftProgress.value =\n leftWidth.value > 0\n ? interpolate(\n appliedTranslation.value,\n [-1, 0, leftWidth.value],\n [0, 0, 1]\n )\n : 0;\n\n showRightProgress.value =\n rightWidth.value > 0\n ? interpolate(\n appliedTranslation.value,\n [-rightWidth.value, 0, 1],\n [1, 0, 0]\n )\n : 0;\n }, [\n appliedTranslation,\n friction,\n leftWidth,\n overshootFriction,\n rightWidth,\n rowState,\n showLeftProgress,\n showRightProgress,\n userDrag,\n overshootLeft,\n overshootRight,\n ]);\n\n const dispatchImmediateEvents = useCallback(\n (fromValue: number, toValue: number) => {\n 'worklet';\n if (toValue > 0 && onSwipeableWillOpen) {\n runOnJS(onSwipeableWillOpen)(SwipeDirection.RIGHT);\n } else if (toValue < 0 && onSwipeableWillOpen) {\n runOnJS(onSwipeableWillOpen)(SwipeDirection.LEFT);\n } else if (onSwipeableWillClose) {\n runOnJS(onSwipeableWillClose)(\n fromValue > 0 ? SwipeDirection.LEFT : SwipeDirection.RIGHT\n );\n }\n },\n [onSwipeableWillClose, onSwipeableWillOpen]\n );\n\n const dispatchEndEvents = useCallback(\n (fromValue: number, toValue: number) => {\n 'worklet';\n if (toValue > 0 && onSwipeableOpen) {\n runOnJS(onSwipeableOpen)(SwipeDirection.RIGHT);\n } else if (toValue < 0 && onSwipeableOpen) {\n runOnJS(onSwipeableOpen)(SwipeDirection.LEFT);\n } else if (onSwipeableClose) {\n runOnJS(onSwipeableClose)(\n fromValue > 0 ? SwipeDirection.LEFT : SwipeDirection.RIGHT\n );\n }\n },\n [onSwipeableClose, onSwipeableOpen]\n );\n\n const animateRow: (toValue: number, velocityX?: number) => void =\n useCallback(\n (toValue: number, velocityX?: number) => {\n 'worklet';\n\n const translationSpringConfig = {\n mass: 2,\n damping: 1000,\n stiffness: 700,\n velocity: velocityX,\n overshootClamping: true,\n reduceMotion: ReduceMotion.System,\n ...animationOptions,\n };\n\n const isClosing = toValue === 0;\n const moveToRight = isClosing ? rowState.value < 0 : toValue > 0;\n\n const usedWidth = isClosing\n ? moveToRight\n ? rightWidth.value\n : leftWidth.value\n : moveToRight\n ? leftWidth.value\n : rightWidth.value;\n\n const progressSpringConfig = {\n ...translationSpringConfig,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 0.01,\n velocity:\n velocityX &&\n interpolate(velocityX, [-usedWidth, usedWidth], [-1, 1]),\n };\n\n const frozenRowState = rowState.value;\n\n appliedTranslation.value = withSpring(\n toValue,\n translationSpringConfig,\n (isFinished) => {\n if (isFinished) {\n dispatchEndEvents(frozenRowState, toValue);\n }\n }\n );\n\n const progressTarget = toValue === 0 ? 0 : 1 * Math.sign(toValue);\n\n showLeftProgress.value = withSpring(\n Math.max(progressTarget, 0),\n progressSpringConfig\n );\n\n showRightProgress.value = withSpring(\n Math.max(-progressTarget, 0),\n progressSpringConfig\n );\n\n dispatchImmediateEvents(frozenRowState, toValue);\n\n rowState.value = Math.sign(toValue);\n },\n [\n rowState,\n animationOptions,\n appliedTranslation,\n showLeftProgress,\n leftWidth,\n showRightProgress,\n rightWidth,\n dispatchImmediateEvents,\n dispatchEndEvents,\n ]\n );\n\n const leftLayoutRef = useAnimatedRef();\n const leftWrapperLayoutRef = useAnimatedRef();\n const rightLayoutRef = useAnimatedRef();\n\n const updateElementWidths = useCallback(() => {\n 'worklet';\n const leftLayout = measure(leftLayoutRef);\n const leftWrapperLayout = measure(leftWrapperLayoutRef);\n const rightLayout = measure(rightLayoutRef);\n leftWidth.value =\n (leftLayout?.pageX ?? 0) - (leftWrapperLayout?.pageX ?? 0);\n\n rightWidth.value =\n rowWidth.value -\n (rightLayout?.pageX ?? rowWidth.value) +\n (leftWrapperLayout?.pageX ?? 0);\n }, [\n leftLayoutRef,\n leftWrapperLayoutRef,\n rightLayoutRef,\n leftWidth,\n rightWidth,\n rowWidth.value,\n ]);\n\n const swipeableMethods = useMemo<SwipeableMethods>(\n () => ({\n close() {\n 'worklet';\n if (_WORKLET) {\n animateRow(0);\n return;\n }\n runOnUI(() => {\n animateRow(0);\n })();\n },\n openLeft() {\n 'worklet';\n if (_WORKLET) {\n updateElementWidths();\n animateRow(leftWidth.value);\n return;\n }\n runOnUI(() => {\n updateElementWidths();\n animateRow(leftWidth.value);\n })();\n },\n openRight() {\n 'worklet';\n if (_WORKLET) {\n updateElementWidths();\n animateRow(-rightWidth.value);\n return;\n }\n runOnUI(() => {\n updateElementWidths();\n animateRow(-rightWidth.value);\n })();\n },\n reset() {\n 'worklet';\n userDrag.value = 0;\n showLeftProgress.value = 0;\n appliedTranslation.value = 0;\n rowState.value = 0;\n },\n }),\n [\n animateRow,\n updateElementWidths,\n leftWidth,\n rightWidth,\n userDrag,\n showLeftProgress,\n appliedTranslation,\n rowState,\n ]\n );\n\n const onRowLayout = useCallback(\n ({ nativeEvent }: LayoutChangeEvent) => {\n rowWidth.value = nativeEvent.layout.width;\n },\n [rowWidth]\n );\n\n // As stated in `Dimensions.get` docstring, this function should be called on every render\n // since dimensions may change (e.g. orientation change)\n\n const leftActionAnimation = useAnimatedStyle(() => {\n return {\n opacity: showLeftProgress.value === 0 ? 0 : 1,\n };\n });\n\n const leftElement = useCallback(\n () => (\n <Animated.View\n ref={leftWrapperLayoutRef}\n style={[styles.leftActions, leftActionAnimation]}>\n {renderLeftActions?.(\n showLeftProgress,\n appliedTranslation,\n swipeableMethods\n )}\n <Animated.View ref={leftLayoutRef} />\n </Animated.View>\n ),\n [\n appliedTranslation,\n leftActionAnimation,\n leftLayoutRef,\n leftWrapperLayoutRef,\n renderLeftActions,\n showLeftProgress,\n swipeableMethods,\n ]\n );\n\n const rightActionAnimation = useAnimatedStyle(() => {\n return {\n opacity: showRightProgress.value === 0 ? 0 : 1,\n };\n });\n\n const rightElement = useCallback(\n () => (\n <Animated.View style={[styles.rightActions, rightActionAnimation]}>\n {renderRightActions?.(\n showRightProgress,\n appliedTranslation,\n swipeableMethods\n )}\n <Animated.View ref={rightLayoutRef} />\n </Animated.View>\n ),\n [\n appliedTranslation,\n renderRightActions,\n rightActionAnimation,\n rightLayoutRef,\n showRightProgress,\n swipeableMethods,\n ]\n );\n\n const handleRelease = useCallback(\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\n 'worklet';\n const { velocityX } = event;\n userDrag.value = event.translationX;\n\n const leftThresholdProp = leftThreshold ?? leftWidth.value / 2;\n const rightThresholdProp = rightThreshold ?? rightWidth.value / 2;\n\n const translationX =\n (userDrag.value + DRAG_TOSS * velocityX) / friction;\n\n let toValue = 0;\n\n if (rowState.value === 0) {\n if (translationX > leftThresholdProp) {\n toValue = leftWidth.value;\n } else if (translationX < -rightThresholdProp) {\n toValue = -rightWidth.value;\n }\n } else if (rowState.value === 1) {\n // Swiped to left\n if (translationX > -leftThresholdProp) {\n toValue = leftWidth.value;\n }\n } else {\n // Swiped to right\n if (translationX < rightThresholdProp) {\n toValue = -rightWidth.value;\n }\n }\n\n animateRow(toValue, velocityX / friction);\n },\n [\n animateRow,\n friction,\n leftThreshold,\n leftWidth,\n rightThreshold,\n rightWidth,\n rowState,\n userDrag,\n ]\n );\n\n const close = useCallback(() => {\n 'worklet';\n animateRow(0);\n }, [animateRow]);\n\n const dragStarted = useSharedValue<boolean>(false);\n\n const tapGesture = useMemo(\n () =>\n Gesture.Tap()\n .shouldCancelWhenOutside(true)\n .onStart(() => {\n if (rowState.value !== 0) {\n close();\n }\n }),\n [close, rowState]\n );\n\n const panGesture = useMemo(\n () =>\n Gesture.Pan()\n .enabled(enabled !== false)\n .enableTrackpadTwoFingerGesture(enableTrackpadTwoFingerGesture)\n .activeOffsetX([-dragOffsetFromRightEdge, dragOffsetFromLeftEdge])\n .onStart(updateElementWidths)\n .onUpdate(\n (event: GestureUpdateEvent<PanGestureHandlerEventPayload>) => {\n userDrag.value = event.translationX;\n\n const direction =\n rowState.value === -1\n ? SwipeDirection.RIGHT\n : rowState.value === 1\n ? SwipeDirection.LEFT\n : event.translationX > 0\n ? SwipeDirection.RIGHT\n : SwipeDirection.LEFT;\n\n if (!dragStarted.value) {\n dragStarted.value = true;\n if (rowState.value === 0 && onSwipeableOpenStartDrag) {\n runOnJS(onSwipeableOpenStartDrag)(direction);\n } else if (onSwipeableCloseStartDrag) {\n runOnJS(onSwipeableCloseStartDrag)(direction);\n }\n }\n\n updateAnimatedEvent();\n }\n )\n .onEnd(\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\n handleRelease(event);\n }\n )\n .onFinalize(() => {\n dragStarted.value = false;\n }),\n [\n dragOffsetFromLeftEdge,\n dragOffsetFromRightEdge,\n dragStarted,\n enableTrackpadTwoFingerGesture,\n enabled,\n handleRelease,\n onSwipeableCloseStartDrag,\n onSwipeableOpenStartDrag,\n rowState,\n updateAnimatedEvent,\n updateElementWidths,\n userDrag,\n ]\n );\n\n useImperativeHandle(ref, () => swipeableMethods, [swipeableMethods]);\n\n const animatedStyle = useAnimatedStyle(\n () => ({\n transform: [{ translateX: appliedTranslation.value }],\n pointerEvents: rowState.value === 0 ? 'auto' : 'box-only',\n }),\n [appliedTranslation, rowState]\n );\n\n const swipeableComponent = (\n <GestureDetector gesture={panGesture} touchAction=\"pan-y\">\n <Animated.View\n {...remainingProps}\n onLayout={onRowLayout}\n style={[styles.container, containerStyle]}>\n {leftElement()}\n {rightElement()}\n <GestureDetector gesture={tapGesture} touchAction=\"pan-y\">\n <Animated.View style={[animatedStyle, childrenContainerStyle]}>\n {children}\n </Animated.View>\n </GestureDetector>\n </Animated.View>\n </GestureDetector>\n );\n\n return testID ? (\n <View testID={testID}>{swipeableComponent}</View>\n ) : (\n swipeableComponent\n );\n }\n);\n\nexport default Swipeable;\nexport type SwipeableRef = ForwardedRef<SwipeableMethods>;\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n leftActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',\n overflow: 'hidden',\n },\n rightActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',\n overflow: 'hidden',\n },\n});\n"]}
|
@@ -17,19 +17,30 @@ export default function createNativeWrapper(Component, config = {}) {
|
|
17
17
|
|
18
18
|
const ComponentWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
|
19
19
|
// Filter out props that should be passed to gesture handler wrapper
|
20
|
-
const
|
20
|
+
const {
|
21
|
+
gestureHandlerProps,
|
22
|
+
childProps
|
23
|
+
} = Object.keys(props).reduce((res, key) => {
|
21
24
|
// TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info
|
22
25
|
const allowedKeys = NATIVE_WRAPPER_PROPS_FILTER;
|
23
26
|
|
24
27
|
if (allowedKeys.includes(key)) {
|
25
28
|
// @ts-ignore FIXME(TS)
|
26
|
-
res[key] = props[key];
|
29
|
+
res.gestureHandlerProps[key] = props[key];
|
30
|
+
} else {
|
31
|
+
// @ts-ignore FIXME(TS)
|
32
|
+
res.childProps[key] = props[key];
|
27
33
|
}
|
28
34
|
|
29
35
|
return res;
|
30
|
-
}, {
|
31
|
-
|
32
|
-
|
36
|
+
}, {
|
37
|
+
gestureHandlerProps: { ...config
|
38
|
+
},
|
39
|
+
// Watch out not to modify config
|
40
|
+
childProps: {
|
41
|
+
enabled: props.enabled
|
42
|
+
}
|
43
|
+
});
|
33
44
|
|
34
45
|
const _ref = useRef();
|
35
46
|
|
@@ -50,7 +61,7 @@ export default function createNativeWrapper(Component, config = {}) {
|
|
50
61
|
return /*#__PURE__*/React.createElement(NativeViewGestureHandler, _extends({}, gestureHandlerProps, {
|
51
62
|
// @ts-ignore TODO(TS)
|
52
63
|
ref: _gestureHandlerRef
|
53
|
-
}), /*#__PURE__*/React.createElement(Component, _extends({},
|
64
|
+
}), /*#__PURE__*/React.createElement(Component, _extends({}, childProps, {
|
54
65
|
ref: _ref
|
55
66
|
})));
|
56
67
|
}); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createNativeWrapper.tsx"],"names":["React","useImperativeHandle","useRef","NativeViewGestureHandler","nativeViewProps","NATIVE_WRAPPER_PROPS_FILTER","createNativeWrapper","Component","config","ComponentWrapper","forwardRef","props","ref","gestureHandlerProps","Object","keys","reduce","res","key","allowedKeys","includes","_ref","_gestureHandlerRef","node","current","handlerTag","displayName","render","name"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,mBAAT,EAA8BC,MAA9B,QAA4C,OAA5C;AAEA,SACEC,wBADF,EAGEC,eAHF,QAIO,4BAJP;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG,CAClC,GAAGD,eAD+B,EAElC,uBAFkC,EAGlC,6BAHkC,CAApC;AAMA,eAAe,SAASE,mBAAT,CACbC,SADa,EAEbC,MAA+C,GAAG,EAFrC,EAGb;AAAA;;AACA,QAAMC,gBAAgB,gBAAGT,KAAK,CAACU,UAAN,CAGvB,CAACC,KAAD,EAAQC,GAAR,KAAgB;AAChB;AACA,
|
1
|
+
{"version":3,"sources":["createNativeWrapper.tsx"],"names":["React","useImperativeHandle","useRef","NativeViewGestureHandler","nativeViewProps","NATIVE_WRAPPER_PROPS_FILTER","createNativeWrapper","Component","config","ComponentWrapper","forwardRef","props","ref","gestureHandlerProps","childProps","Object","keys","reduce","res","key","allowedKeys","includes","enabled","_ref","_gestureH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jB;AACA,UAAM;AACJ,YAAMa,IAAI,GAAGD,kBAAkB,CAACE,OAAhC,CADI,CAEJ;;AACA,UAAIH,IAAI,CAACG,OAAL,IAAgBD,IAApB,EAA0B;AACxB;AACAF,QAAAA,IAAI,CAACG,OAAL,CAAaC,UAAb,GAA0BF,IAAI,CAACE,UAA/B;AACA,eAAOJ,IAAI,CAACG,OAAZ;AACD;;AACD,aAAO,IAAP;AACD,KAZgB,EAajB,CAACH,IAAD,EAAOC,kBAAP,CAbiB,CAAnB;AAeA,wBACE,oBAAC,wBAAD,eACMX,mBADN;AAEE;AACA,MAAA,GAAG,EAAEW;AAHP,qBAIE,oBAAC,SAAD,eAAeV,UAAf;AAA2B,MAAA,GAAG,EAAES;AAAhC,OAJF,CADF;AAQD,GAhDwB,CAAzB,CADA,CAmDA;;AACAd,EAAAA,gBAAgB,CAACmB,WAAjB,GACE,CAAArB,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEqB,WAAX,OACA;AACArB,EAAAA,SAFA,aAEAA,SAFA,4CAEAA,SAAS,CAAEsB,MAFX,sDAEA,kBAAmBC,IAFnB,KAGC,OAAOvB,SAAP,KAAqB,QAArB,IAAiCA,SAHlC,IAIA,kBALF;AAOA,SAAOE,gBAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { useImperativeHandle, useRef } from 'react';\n\nimport {\n NativeViewGestureHandler,\n NativeViewGestureHandlerProps,\n nativeViewProps,\n} from './NativeViewGestureHandler';\n\n/*\n * This array should consist of:\n * - All keys in propTypes from NativeGestureHandler\n * (and all keys in GestureHandlerPropTypes)\n * - 'onGestureHandlerEvent'\n * - 'onGestureHandlerStateChange'\n */\nconst NATIVE_WRAPPER_PROPS_FILTER = [\n ...nativeViewProps,\n 'onGestureHandlerEvent',\n 'onGestureHandlerStateChange',\n] as const;\n\nexport default function createNativeWrapper<P>(\n Component: React.ComponentType<P>,\n config: Readonly<NativeViewGestureHandlerProps> = {}\n) {\n const ComponentWrapper = React.forwardRef<\n React.ComponentType<any>,\n P & NativeViewGestureHandlerProps\n >((props, ref) => {\n // Filter out props that should be passed to gesture handler wrapper\n const { gestureHandlerProps, childProps } = Object.keys(props).reduce(\n (res, key) => {\n // TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info\n const allowedKeys: readonly string[] = NATIVE_WRAPPER_PROPS_FILTER;\n if (allowedKeys.includes(key)) {\n // @ts-ignore FIXME(TS)\n res.gestureHandlerProps[key] = props[key];\n } else {\n // @ts-ignore FIXME(TS)\n res.childProps[key] = props[key];\n }\n return res;\n },\n {\n gestureHandlerProps: { ...config }, // Watch out not to modify config\n childProps: { enabled: props.enabled } as P,\n }\n );\n const _ref = useRef<React.ComponentType<P>>();\n const _gestureHandlerRef = useRef<React.ComponentType<P>>();\n useImperativeHandle(\n ref,\n // @ts-ignore TODO(TS) decide how nulls work in this context\n () => {\n const node = _gestureHandlerRef.current;\n // Add handlerTag for relations config\n if (_ref.current && node) {\n // @ts-ignore FIXME(TS) think about createHandler return type\n _ref.current.handlerTag = node.handlerTag;\n return _ref.current;\n }\n return null;\n },\n [_ref, _gestureHandlerRef]\n );\n return (\n <NativeViewGestureHandler\n {...gestureHandlerProps}\n // @ts-ignore TODO(TS)\n ref={_gestureHandlerRef}>\n <Component {...childProps} ref={_ref} />\n </NativeViewGestureHandler>\n );\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n ComponentWrapper.displayName =\n Component?.displayName ||\n // @ts-ignore if render doesn't exist it will return undefined and go further\n Component?.render?.name ||\n (typeof Component === 'string' && Component) ||\n 'ComponentWrapper';\n\n return ComponentWrapper;\n}\n"]}
|
package/package.json
CHANGED