react-native-gesture-handler 2.20.2 → 2.21.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/RNGestureHandler.podspec +9 -0
- package/ReanimatedDrawerLayout/package.json +6 -0
- package/android/build.gradle +19 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +6 -2
- package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureDetector.kt +53 -21
- package/apple/RNGestureHandlerPointerTracker.m +4 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js +15 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +2 -6
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/ReanimatedDrawerLayout.js +389 -0
- package/lib/commonjs/components/ReanimatedDrawerLayout.js.map +1 -0
- package/lib/commonjs/components/ReanimatedSwipeable.js +117 -148
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/findNodeHandle.js +12 -0
- package/lib/commonjs/findNodeHandle.js.map +1 -0
- package/lib/commonjs/findNodeHandle.web.js +40 -0
- package/lib/commonjs/findNodeHandle.web.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +4 -2
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.web.js +51 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.web.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +3 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +5 -3
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +4 -2
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +4 -0
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +59 -0
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js +10 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/EventManager.js +6 -0
- package/lib/commonjs/web/tools/EventManager.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -3
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +5 -2
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/KeyboardEventManager.js +2 -2
- package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +6 -30
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/WheelEventManager.js +74 -0
- package/lib/commonjs/web/tools/WheelEventManager.js.map +1 -0
- package/lib/commonjs/web/utils.js +16 -0
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +16 -3
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +2 -6
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/ReanimatedDrawerLayout.js +365 -0
- package/lib/module/components/ReanimatedDrawerLayout.js.map +1 -0
- package/lib/module/components/ReanimatedSwipeable.js +119 -145
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/findNodeHandle.js +3 -0
- package/lib/module/findNodeHandle.js.map +1 -0
- package/lib/module/findNodeHandle.web.js +32 -0
- package/lib/module/findNodeHandle.web.js.map +1 -0
- package/lib/module/handlers/createHandler.js +2 -1
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/Wrap.web.js +34 -0
- package/lib/module/handlers/gestures/GestureDetector/Wrap.web.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js +2 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +2 -2
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +4 -0
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +58 -0
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js +8 -0
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/EventManager.js +6 -0
- package/lib/module/web/tools/EventManager.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -3
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +3 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/KeyboardEventManager.js +2 -2
- package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +6 -30
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/WheelEventManager.js +60 -0
- package/lib/module/web/tools/WheelEventManager.js.map +1 -0
- package/lib/module/web/utils.js +15 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +162 -0
- package/lib/typescript/components/ReanimatedSwipeable.d.ts +22 -16
- package/lib/typescript/findNodeHandle.d.ts +2 -0
- package/lib/typescript/findNodeHandle.web.d.ts +2 -0
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +7 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +2 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +5 -0
- package/lib/typescript/web/interfaces.d.ts +16 -0
- package/lib/typescript/web/tools/EventManager.d.ts +2 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +2 -8
- package/lib/typescript/web/tools/WheelEventManager.d.ts +11 -0
- package/lib/typescript/web/utils.d.ts +2 -1
- package/package.json +3 -2
- package/src/RNGestureHandlerModule.web.ts +23 -4
- package/src/components/Pressable/Pressable.tsx +2 -6
- package/src/components/ReanimatedDrawerLayout.tsx +741 -0
- package/src/components/ReanimatedSwipeable.tsx +361 -305
- package/src/findNodeHandle.ts +3 -0
- package/src/findNodeHandle.web.ts +35 -0
- package/src/handlers/createHandler.tsx +2 -1
- package/src/handlers/gestures/GestureDetector/Wrap.web.tsx +44 -0
- package/src/handlers/gestures/GestureDetector/index.tsx +2 -1
- package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -1
- package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +1 -1
- package/src/web/handlers/GestureHandler.ts +5 -1
- package/src/web/handlers/PanGestureHandler.ts +69 -1
- package/src/web/interfaces.ts +17 -0
- package/src/web/tools/EventManager.ts +4 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
- package/src/web/tools/GestureHandlerWebDelegate.ts +3 -1
- package/src/web/tools/KeyboardEventManager.ts +2 -2
- package/src/web/tools/PointerTracker.ts +6 -28
- package/src/web/tools/WheelEventManager.ts +48 -0
- package/src/web/utils.ts +47 -1
|
@@ -22,24 +22,44 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
22
22
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
23
|
|
|
24
24
|
const DRAG_TOSS = 0.05;
|
|
25
|
+
var SwipeDirection;
|
|
26
|
+
|
|
27
|
+
(function (SwipeDirection) {
|
|
28
|
+
SwipeDirection["LEFT"] = "left";
|
|
29
|
+
SwipeDirection["RIGHT"] = "right";
|
|
30
|
+
})(SwipeDirection || (SwipeDirection = {}));
|
|
31
|
+
|
|
25
32
|
const Swipeable = /*#__PURE__*/(0, _react.forwardRef)(function Swipeable(props, ref) {
|
|
33
|
+
const defaultProps = {
|
|
34
|
+
friction: 1,
|
|
35
|
+
overshootFriction: 1,
|
|
36
|
+
dragOffset: 10,
|
|
37
|
+
enableTrackpadTwoFingerGesture: false
|
|
38
|
+
};
|
|
26
39
|
const {
|
|
27
40
|
leftThreshold,
|
|
28
41
|
rightThreshold,
|
|
29
|
-
onSwipeableOpenStartDrag,
|
|
30
|
-
onSwipeableCloseStartDrag,
|
|
31
|
-
enableTrackpadTwoFingerGesture,
|
|
32
42
|
enabled,
|
|
33
43
|
containerStyle,
|
|
34
44
|
childrenContainerStyle,
|
|
35
45
|
animationOptions,
|
|
36
46
|
overshootLeft,
|
|
37
47
|
overshootRight,
|
|
48
|
+
testID,
|
|
49
|
+
children,
|
|
50
|
+
enableTrackpadTwoFingerGesture = defaultProps.enableTrackpadTwoFingerGesture,
|
|
51
|
+
dragOffsetFromLeftEdge = defaultProps.dragOffset,
|
|
52
|
+
dragOffsetFromRightEdge = defaultProps.dragOffset,
|
|
53
|
+
friction = defaultProps.friction,
|
|
54
|
+
overshootFriction = defaultProps.overshootFriction,
|
|
55
|
+
onSwipeableOpenStartDrag,
|
|
56
|
+
onSwipeableCloseStartDrag,
|
|
38
57
|
onSwipeableWillOpen,
|
|
39
58
|
onSwipeableWillClose,
|
|
40
59
|
onSwipeableOpen,
|
|
41
60
|
onSwipeableClose,
|
|
42
|
-
|
|
61
|
+
renderLeftActions,
|
|
62
|
+
renderRightActions,
|
|
43
63
|
...remainingProps
|
|
44
64
|
} = props;
|
|
45
65
|
const rowState = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
@@ -47,141 +67,103 @@ const Swipeable = /*#__PURE__*/(0, _react.forwardRef)(function Swipeable(props,
|
|
|
47
67
|
const appliedTranslation = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
48
68
|
const rowWidth = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
49
69
|
const leftWidth = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
50
|
-
const rightWidth = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const rightActionTranslate = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
70
|
+
const rightWidth = (0, _reactNativeReanimated.useSharedValue)(0); // used for synchronizing layout measurements between JS and UI
|
|
71
|
+
|
|
72
|
+
const rightOffset = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
54
73
|
const showLeftProgress = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
55
74
|
const showRightProgress = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
56
|
-
const
|
|
57
|
-
close: () => {
|
|
58
|
-
'worklet';
|
|
59
|
-
},
|
|
60
|
-
openLeft: () => {
|
|
61
|
-
'worklet';
|
|
62
|
-
},
|
|
63
|
-
openRight: () => {
|
|
64
|
-
'worklet';
|
|
65
|
-
},
|
|
66
|
-
reset: () => {
|
|
67
|
-
'worklet';
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
const defaultProps = {
|
|
71
|
-
friction: 1,
|
|
72
|
-
overshootFriction: 1
|
|
73
|
-
};
|
|
74
|
-
const {
|
|
75
|
-
friction = defaultProps.friction,
|
|
76
|
-
overshootFriction = defaultProps.overshootFriction
|
|
77
|
-
} = props;
|
|
78
|
-
const overshootLeftProp = overshootLeft;
|
|
79
|
-
const overshootRightProp = overshootRight;
|
|
80
|
-
const calculateCurrentOffset = (0, _react.useCallback)(() => {
|
|
75
|
+
const updateRightElementWidth = (0, _react.useCallback)(() => {
|
|
81
76
|
'worklet';
|
|
82
77
|
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
} else if (rowState.value === -1) {
|
|
86
|
-
return -rowWidth.value - rightOffset.value;
|
|
78
|
+
if (rightOffset.value === null) {
|
|
79
|
+
rightOffset.value = rowWidth.value;
|
|
87
80
|
}
|
|
88
81
|
|
|
89
|
-
|
|
90
|
-
}, [
|
|
91
|
-
|
|
92
|
-
const updateAnimatedEvent = () => {
|
|
82
|
+
rightWidth.value = Math.max(0, rowWidth.value - rightOffset.value);
|
|
83
|
+
}, [rightOffset, rightWidth, rowWidth]);
|
|
84
|
+
const updateAnimatedEvent = (0, _react.useCallback)(() => {
|
|
93
85
|
'worklet';
|
|
94
86
|
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
const overshootRight = overshootRightProp !== null && overshootRightProp !== void 0 ? overshootRightProp : rightWidth.value > 0;
|
|
87
|
+
const shouldOvershootLeft = overshootLeft !== null && overshootLeft !== void 0 ? overshootLeft : leftWidth.value > 0;
|
|
88
|
+
const shouldOvershootRight = overshootRight !== null && overshootRight !== void 0 ? overshootRight : rightWidth.value > 0;
|
|
98
89
|
const startOffset = rowState.value === 1 ? leftWidth.value : rowState.value === -1 ? -rightWidth.value : 0;
|
|
99
90
|
const offsetDrag = userDrag.value / friction + startOffset;
|
|
100
|
-
appliedTranslation.value = (0, _reactNativeReanimated.interpolate)(offsetDrag, [-rightWidth.value - 1, -rightWidth.value, leftWidth.value, leftWidth.value + 1], [-rightWidth.value - (
|
|
91
|
+
appliedTranslation.value = (0, _reactNativeReanimated.interpolate)(offsetDrag, [-rightWidth.value - 1, -rightWidth.value, leftWidth.value, leftWidth.value + 1], [-rightWidth.value - (shouldOvershootRight ? 1 / overshootFriction : 0), -rightWidth.value, leftWidth.value, leftWidth.value + (shouldOvershootLeft ? 1 / overshootFriction : 0)]);
|
|
101
92
|
showLeftProgress.value = leftWidth.value > 0 ? (0, _reactNativeReanimated.interpolate)(appliedTranslation.value, [-1, 0, leftWidth.value], [0, 0, 1]) : 0;
|
|
102
|
-
leftActionTranslate.value = (0, _reactNativeReanimated.interpolate)(showLeftProgress.value, [0, Number.MIN_VALUE], [-10000, 0], _reactNativeReanimated.Extrapolation.CLAMP);
|
|
103
93
|
showRightProgress.value = rightWidth.value > 0 ? (0, _reactNativeReanimated.interpolate)(appliedTranslation.value, [-rightWidth.value, 0, 1], [1, 0, 0]) : 0;
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
|
|
94
|
+
}, [appliedTranslation, friction, leftWidth, overshootFriction, rightWidth, rowState, showLeftProgress, showRightProgress, userDrag, overshootLeft, overshootRight]);
|
|
107
95
|
const dispatchImmediateEvents = (0, _react.useCallback)((fromValue, toValue) => {
|
|
96
|
+
'worklet';
|
|
97
|
+
|
|
108
98
|
if (toValue > 0 && onSwipeableWillOpen) {
|
|
109
|
-
onSwipeableWillOpen(
|
|
99
|
+
(0, _reactNativeReanimated.runOnJS)(onSwipeableWillOpen)(SwipeDirection.RIGHT);
|
|
110
100
|
} else if (toValue < 0 && onSwipeableWillOpen) {
|
|
111
|
-
onSwipeableWillOpen(
|
|
101
|
+
(0, _reactNativeReanimated.runOnJS)(onSwipeableWillOpen)(SwipeDirection.LEFT);
|
|
112
102
|
} else if (onSwipeableWillClose) {
|
|
113
|
-
|
|
114
|
-
onSwipeableWillClose(closingDirection);
|
|
103
|
+
(0, _reactNativeReanimated.runOnJS)(onSwipeableWillClose)(fromValue > 0 ? SwipeDirection.LEFT : SwipeDirection.RIGHT);
|
|
115
104
|
}
|
|
116
105
|
}, [onSwipeableWillClose, onSwipeableWillOpen]);
|
|
117
106
|
const dispatchEndEvents = (0, _react.useCallback)((fromValue, toValue) => {
|
|
107
|
+
'worklet';
|
|
108
|
+
|
|
118
109
|
if (toValue > 0 && onSwipeableOpen) {
|
|
119
|
-
|
|
110
|
+
(0, _reactNativeReanimated.runOnJS)(onSwipeableOpen)(SwipeDirection.RIGHT);
|
|
120
111
|
} else if (toValue < 0 && onSwipeableOpen) {
|
|
121
|
-
|
|
112
|
+
(0, _reactNativeReanimated.runOnJS)(onSwipeableOpen)(SwipeDirection.LEFT);
|
|
122
113
|
} else if (onSwipeableClose) {
|
|
123
|
-
|
|
124
|
-
onSwipeableClose(closingDirection, swipeableMethods.current);
|
|
114
|
+
(0, _reactNativeReanimated.runOnJS)(onSwipeableClose)(fromValue > 0 ? SwipeDirection.LEFT : SwipeDirection.RIGHT);
|
|
125
115
|
}
|
|
126
116
|
}, [onSwipeableClose, onSwipeableOpen]);
|
|
127
|
-
const
|
|
128
|
-
const animateRow = (0, _react.useCallback)((fromValue, toValue, velocityX) => {
|
|
117
|
+
const animateRow = (0, _react.useCallback)((toValue, velocityX) => {
|
|
129
118
|
'worklet';
|
|
130
119
|
|
|
131
|
-
rowState.value = Math.sign(toValue);
|
|
132
120
|
const translationSpringConfig = {
|
|
133
121
|
duration: 1000,
|
|
134
122
|
dampingRatio: 0.9,
|
|
135
123
|
stiffness: 500,
|
|
136
124
|
velocity: velocityX,
|
|
137
125
|
overshootClamping: true,
|
|
138
|
-
...
|
|
126
|
+
...animationOptions
|
|
139
127
|
};
|
|
128
|
+
const isClosing = toValue === 0;
|
|
129
|
+
const moveToRight = isClosing ? rowState.value < 0 : toValue > 0;
|
|
130
|
+
const usedWidth = isClosing ? moveToRight ? rightWidth.value : leftWidth.value : moveToRight ? leftWidth.value : rightWidth.value;
|
|
140
131
|
const progressSpringConfig = { ...translationSpringConfig,
|
|
141
|
-
|
|
132
|
+
restDisplacementThreshold: 0.01,
|
|
133
|
+
restSpeedThreshold: 0.01,
|
|
134
|
+
velocity: velocityX && (0, _reactNativeReanimated.interpolate)(velocityX, [-usedWidth, usedWidth], [-1, 1])
|
|
142
135
|
};
|
|
136
|
+
const frozenRowState = rowState.value;
|
|
143
137
|
appliedTranslation.value = (0, _reactNativeReanimated.withSpring)(toValue, translationSpringConfig, isFinished => {
|
|
144
138
|
if (isFinished) {
|
|
145
|
-
|
|
139
|
+
dispatchEndEvents(frozenRowState, toValue);
|
|
146
140
|
}
|
|
147
141
|
});
|
|
148
142
|
const progressTarget = toValue === 0 ? 0 : 1;
|
|
149
143
|
showLeftProgress.value = leftWidth.value > 0 ? (0, _reactNativeReanimated.withSpring)(progressTarget, progressSpringConfig) : 0;
|
|
150
144
|
showRightProgress.value = rightWidth.value > 0 ? (0, _reactNativeReanimated.withSpring)(progressTarget, progressSpringConfig) : 0;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
nativeEvent
|
|
156
|
-
}) => {
|
|
157
|
-
rowWidth.value = nativeEvent.layout.width;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const {
|
|
161
|
-
children,
|
|
162
|
-
renderLeftActions,
|
|
163
|
-
renderRightActions,
|
|
164
|
-
dragOffsetFromLeftEdge = 10,
|
|
165
|
-
dragOffsetFromRightEdge = 10
|
|
166
|
-
} = props;
|
|
167
|
-
swipeableMethods.current = {
|
|
145
|
+
dispatchImmediateEvents(frozenRowState, toValue);
|
|
146
|
+
rowState.value = Math.sign(toValue);
|
|
147
|
+
}, [rowState, animationOptions, appliedTranslation, showLeftProgress, leftWidth, showRightProgress, rightWidth, dispatchImmediateEvents, dispatchEndEvents]);
|
|
148
|
+
const swipeableMethods = (0, _react.useMemo)(() => ({
|
|
168
149
|
close() {
|
|
169
150
|
'worklet';
|
|
170
151
|
|
|
171
|
-
animateRow(
|
|
152
|
+
animateRow(0);
|
|
172
153
|
},
|
|
173
154
|
|
|
174
155
|
openLeft() {
|
|
175
156
|
'worklet';
|
|
176
157
|
|
|
177
|
-
animateRow(
|
|
158
|
+
animateRow(leftWidth.value);
|
|
178
159
|
},
|
|
179
160
|
|
|
180
161
|
openRight() {
|
|
181
|
-
'worklet';
|
|
162
|
+
'worklet'; // rightOffset and rowWidth are already much sooner than rightWidth
|
|
182
163
|
|
|
183
|
-
|
|
184
|
-
|
|
164
|
+
var _rightOffset$value;
|
|
165
|
+
|
|
166
|
+
animateRow(((_rightOffset$value = rightOffset.value) !== null && _rightOffset$value !== void 0 ? _rightOffset$value : 0) - rowWidth.value);
|
|
185
167
|
},
|
|
186
168
|
|
|
187
169
|
reset() {
|
|
@@ -193,108 +175,95 @@ const Swipeable = /*#__PURE__*/(0, _react.forwardRef)(function Swipeable(props,
|
|
|
193
175
|
rowState.value = 0;
|
|
194
176
|
}
|
|
195
177
|
|
|
196
|
-
};
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}, renderLeftActions(showLeftProgress, appliedTranslation, swipeableMethods.current), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
178
|
+
}), [leftWidth, rightOffset, rowWidth, userDrag, showLeftProgress, appliedTranslation, rowState, animateRow]);
|
|
179
|
+
const onRowLayout = (0, _react.useCallback)(({
|
|
180
|
+
nativeEvent
|
|
181
|
+
}) => {
|
|
182
|
+
rowWidth.value = nativeEvent.layout.width;
|
|
183
|
+
}, [rowWidth]);
|
|
184
|
+
const leftElement = (0, _react.useCallback)(() => /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
185
|
+
style: [styles.leftActions]
|
|
186
|
+
}, renderLeftActions === null || renderLeftActions === void 0 ? void 0 : renderLeftActions(showLeftProgress, appliedTranslation, swipeableMethods), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
206
187
|
onLayout: ({
|
|
207
188
|
nativeEvent
|
|
208
189
|
}) => leftWidth.value = nativeEvent.layout.x
|
|
209
|
-
}));
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
translateX: rightActionTranslate.value
|
|
214
|
-
}]
|
|
215
|
-
}), [rightActionTranslate]);
|
|
216
|
-
|
|
217
|
-
const rightElement = renderRightActions && /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
218
|
-
style: [styles.rightActions, rightAnimatedStyle]
|
|
219
|
-
}, renderRightActions(showRightProgress, appliedTranslation, swipeableMethods.current), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
190
|
+
})), [appliedTranslation, leftWidth, renderLeftActions, showLeftProgress, swipeableMethods]);
|
|
191
|
+
const rightElement = (0, _react.useCallback)(() => /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
192
|
+
style: [styles.rightActions]
|
|
193
|
+
}, renderRightActions === null || renderRightActions === void 0 ? void 0 : renderRightActions(showRightProgress, appliedTranslation, swipeableMethods), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
220
194
|
onLayout: ({
|
|
221
195
|
nativeEvent
|
|
222
|
-
}) =>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
const handleRelease = event => {
|
|
196
|
+
}) => {
|
|
197
|
+
rightOffset.value = nativeEvent.layout.x;
|
|
198
|
+
}
|
|
199
|
+
})), [appliedTranslation, renderRightActions, rightOffset, showRightProgress, swipeableMethods]);
|
|
200
|
+
const handleRelease = (0, _react.useCallback)(event => {
|
|
229
201
|
'worklet';
|
|
230
202
|
|
|
231
203
|
const {
|
|
232
204
|
velocityX
|
|
233
205
|
} = event;
|
|
234
206
|
userDrag.value = event.translationX;
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
const startOffsetX = calculateCurrentOffset() + userDrag.value / friction;
|
|
207
|
+
updateRightElementWidth();
|
|
208
|
+
const leftThresholdProp = leftThreshold !== null && leftThreshold !== void 0 ? leftThreshold : leftWidth.value / 2;
|
|
209
|
+
const rightThresholdProp = rightThreshold !== null && rightThreshold !== void 0 ? rightThreshold : rightWidth.value / 2;
|
|
239
210
|
const translationX = (userDrag.value + DRAG_TOSS * velocityX) / friction;
|
|
240
211
|
let toValue = 0;
|
|
241
212
|
|
|
242
213
|
if (rowState.value === 0) {
|
|
243
|
-
if (translationX >
|
|
214
|
+
if (translationX > leftThresholdProp) {
|
|
244
215
|
toValue = leftWidth.value;
|
|
245
|
-
} else if (translationX < -
|
|
216
|
+
} else if (translationX < -rightThresholdProp) {
|
|
246
217
|
toValue = -rightWidth.value;
|
|
247
218
|
}
|
|
248
219
|
} else if (rowState.value === 1) {
|
|
249
220
|
// Swiped to left
|
|
250
|
-
if (translationX > -
|
|
221
|
+
if (translationX > -leftThresholdProp) {
|
|
251
222
|
toValue = leftWidth.value;
|
|
252
223
|
}
|
|
253
224
|
} else {
|
|
254
225
|
// Swiped to right
|
|
255
|
-
if (translationX <
|
|
226
|
+
if (translationX < rightThresholdProp) {
|
|
256
227
|
toValue = -rightWidth.value;
|
|
257
228
|
}
|
|
258
229
|
}
|
|
259
230
|
|
|
260
|
-
animateRow(
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const close = () => {
|
|
231
|
+
animateRow(toValue, velocityX / friction);
|
|
232
|
+
}, [animateRow, friction, leftThreshold, leftWidth, rightThreshold, rightWidth, rowState, userDrag, updateRightElementWidth]);
|
|
233
|
+
const close = (0, _react.useCallback)(() => {
|
|
264
234
|
'worklet';
|
|
265
235
|
|
|
266
|
-
animateRow(
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
const tapGesture = _gestureObjects.GestureObjects.Tap().onStart(() => {
|
|
236
|
+
animateRow(0);
|
|
237
|
+
}, [animateRow]);
|
|
238
|
+
const dragStarted = (0, _reactNativeReanimated.useSharedValue)(false);
|
|
239
|
+
const tapGesture = (0, _react.useMemo)(() => _gestureObjects.GestureObjects.Tap().shouldCancelWhenOutside(true).onStart(() => {
|
|
270
240
|
if (rowState.value !== 0) {
|
|
271
241
|
close();
|
|
272
242
|
}
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
|
|
243
|
+
}), [close, rowState]);
|
|
244
|
+
const panGesture = (0, _react.useMemo)(() => _gestureObjects.GestureObjects.Pan().enabled(enabled !== false).enableTrackpadTwoFingerGesture(enableTrackpadTwoFingerGesture).activeOffsetX([-dragOffsetFromRightEdge, dragOffsetFromLeftEdge]).onStart(() => {
|
|
245
|
+
updateRightElementWidth();
|
|
246
|
+
}).onUpdate(event => {
|
|
276
247
|
userDrag.value = event.translationX;
|
|
277
|
-
const direction = rowState.value === -1 ?
|
|
248
|
+
const direction = rowState.value === -1 ? SwipeDirection.RIGHT : rowState.value === 1 ? SwipeDirection.LEFT : event.translationX > 0 ? SwipeDirection.RIGHT : SwipeDirection.LEFT;
|
|
249
|
+
|
|
250
|
+
if (!dragStarted.value) {
|
|
251
|
+
dragStarted.value = true;
|
|
278
252
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
253
|
+
if (rowState.value === 0 && onSwipeableOpenStartDrag) {
|
|
254
|
+
(0, _reactNativeReanimated.runOnJS)(onSwipeableOpenStartDrag)(direction);
|
|
255
|
+
} else if (onSwipeableCloseStartDrag) {
|
|
256
|
+
(0, _reactNativeReanimated.runOnJS)(onSwipeableCloseStartDrag)(direction);
|
|
257
|
+
}
|
|
283
258
|
}
|
|
284
259
|
|
|
285
260
|
updateAnimatedEvent();
|
|
286
261
|
}).onEnd(event => {
|
|
287
262
|
handleRelease(event);
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
panGesture.activeOffsetX([-dragOffsetFromRightEdge, dragOffsetFromLeftEdge]);
|
|
295
|
-
tapGesture.shouldCancelWhenOutside(true);
|
|
296
|
-
(0, _react.useImperativeHandle)(ref, () => swipeableMethods.current, [swipeableMethods]);
|
|
297
|
-
panGesture.enabled(enabled !== false);
|
|
263
|
+
}).onFinalize(() => {
|
|
264
|
+
dragStarted.value = false;
|
|
265
|
+
}), [dragOffsetFromLeftEdge, dragOffsetFromRightEdge, dragStarted, enableTrackpadTwoFingerGesture, enabled, handleRelease, onSwipeableCloseStartDrag, onSwipeableOpenStartDrag, rowState, updateAnimatedEvent, updateRightElementWidth, userDrag]);
|
|
266
|
+
(0, _react.useImperativeHandle)(ref, () => swipeableMethods, [swipeableMethods]);
|
|
298
267
|
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
299
268
|
transform: [{
|
|
300
269
|
translateX: appliedTranslation.value
|
|
@@ -308,7 +277,7 @@ const Swipeable = /*#__PURE__*/(0, _react.forwardRef)(function Swipeable(props,
|
|
|
308
277
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({}, remainingProps, {
|
|
309
278
|
onLayout: onRowLayout,
|
|
310
279
|
style: [styles.container, containerStyle]
|
|
311
|
-
}), leftElement, rightElement, /*#__PURE__*/_react.default.createElement(_GestureDetector.GestureDetector, {
|
|
280
|
+
}), leftElement(), rightElement(), /*#__PURE__*/_react.default.createElement(_GestureDetector.GestureDetector, {
|
|
312
281
|
gesture: tapGesture,
|
|
313
282
|
touchAction: "pan-y"
|
|
314
283
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ReanimatedSwipeable.tsx"],"names":["DRAG_TOSS","Swipeable","props","ref","leftThreshold","rightThreshold","onSwipeableOpenStartDrag","onSwipeableCloseStartDrag","enableTrackpadTwoFingerGesture","enabled","containerStyle","childrenContainerStyle","animationOptions","overshootLeft","overshootRight","onSwipeableWillOpen","onSwipeableWillClose","onSwipeableOpen","onSwipeableClose","testID","remainingProps","rowState","userDrag","appliedTranslation","rowWidth","leftWidth","rightWidth","rightOffset","leftActionTranslate","rightActionTranslate","showLeftProgress","showRightProgress","swipeableMethods","close","openLeft","openRight","reset","defaultProps","friction","overshootFriction","overshootLeftProp","overshootRightProp","calculateCurrentOffset","value","updateAnimatedEvent","Math","max","startOffset","offsetDrag","Number","MIN_VALUE","Extrapolation","CLAMP","dispatchImmediateEvents","fromValue","toValue","closingDirection","dispatchEndEvents","current","animationOptionsProp","animateRow","velocityX","sign","translationSpringConfig","duration","dampingRatio","stiffness","velocity","overshootClamping","progressSpringConfig","isFinished","progressTarget","onRowLayout","nativeEvent","layout","width","children","renderLeftActions","renderRightActions","dragOffsetFromLeftEdge","dragOffsetFromRightEdge","leftAnimatedStyle","transform","translateX","leftElement","styles","leftActions","x","rightAnimatedStyle","rightElement","rightActions","leftThresholdProp","rightThresholdProp","handleRelease","event","translationX","startOffsetX","tapGesture","Gesture","Tap","onStart","panGesture","Pan","onUpdate","direction","onEnd","activeOffsetX","shouldCancelWhenOutside","animatedStyle","pointerEvents","swipeableComponent","container","StyleSheet","create","overflow","absoluteFillObject","flexDirection","I18nManager","isRTL"],"mappings":";;;;;;;AAIA;;AAOA;;AACA;;AAOA;;AASA;;;;;;;;AASA,MAAMA,SAAS,GAAG,IAAlB;AA+JA,MAAMC,SAAS,gBAAG,uBAChB,SAASA,SAAT,CACEC,KADF,EAEEC,GAFF,EAGE;AACA,QAAM;AACJC,IAAAA,aADI;AAEJC,IAAAA,cAFI;AAGJC,IAAAA,wBAHI;AAIJC,IAAAA,yBAJI;AAKJC,IAAAA,8BALI;AAMJC,IAAAA,OANI;AAOJC,IAAAA,cAPI;AAQJC,IAAAA,sBARI;AASJC,IAAAA,gBATI;AAUJC,IAAAA,aAVI;AAWJC,IAAAA,cAXI;AAYJC,IAAAA,mBAZI;AAaJC,IAAAA,oBAbI;AAcJC,IAAAA,eAdI;AAeJC,IAAAA,gBAfI;AAgBJC,IAAAA,MAhBI;AAiBJ,OAAGC;AAjBC,MAkBFlB,KAlBJ;AAoBA,QAAMmB,QAAQ,GAAG,2CAAuB,CAAvB,CAAjB;AAEA,QAAMC,QAAQ,GAAG,2CAAuB,CAAvB,CAAjB;AACA,QAAMC,kBAAkB,GAAG,2CAAuB,CAAvB,CAA3B;AAEA,QAAMC,QAAQ,GAAG,2CAAuB,CAAvB,CAAjB;AACA,QAAMC,SAAS,GAAG,2CAAuB,CAAvB,CAAlB;AACA,QAAMC,UAAU,GAAG,2CAAuB,CAAvB,CAAnB;AACA,QAAMC,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AAEE,IAAA,QAAQ,EAAEoD,WAFZ;AAGE,IAAA,KAAK,EAAE,CAACa,MAAM,CAAC0B,SAAR,EAAmBrG,cAAnB;AAHT,MAIG0E,WAJH,EAKGK,YALH,eAME,6BAAC,gCAAD;AAAiB,IAAA,OAAO,EAAEQ,UAA1B;AAAsC,IAAA,WAAW,EAAC;AAAlD,kBACE,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAE,CAACW,aAAD,EAAgBjG,sBAAhB;AAAtB,KACGiE,QADH,CADF,CANF,CADF,CADF;;AAiBA,SAAOzD,MAAM,gBACX,6BAAC,iBAAD;AAAM,IAAA,MAAM,EAAEA;AAAd,KAAuB2F,kBAAvB,CADW,GAGXA,kBAHF;AAKD,CArbe,CAAlB;eAwbe7G,S;;;AAGf,MAAMoF,MAAM,GAAG2B,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AACTG,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/B5B,EAAAA,WAAW,EAAE,EACX,GAAG0B,wBAAWG,kBADH;AAEXC,IAAAA,aAAa,EAAEC,yBAAYC,KAAZ,GAAoB,aAApB,GAAoC;AAFxC,GAJkB;AAQ/B5B,EAAAA,YAAY,EAAE,EACZ,GAAGsB,wBAAWG,kBADF;AAEZC,IAAAA,aAAa,EAAEC,yBAAYC,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 useRef,\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 Extrapolation,\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\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: 'left' | 'right',\n swipeable: SwipeableMethods\n ) => void;\n\n /**\n * Called when action panel is closed.\n */\n onSwipeableClose?: (\n direction: 'left' | 'right',\n swipeable: SwipeableMethods\n ) => void;\n\n /**\n * Called when action panel starts animating on open (either right or left).\n */\n onSwipeableWillOpen?: (direction: 'left' | 'right') => void;\n\n /**\n * Called when action panel starts animating on close.\n */\n onSwipeableWillClose?: (direction: 'left' | 'right') => void;\n\n /**\n * Called when action panel starts being shown on dragging to open.\n */\n onSwipeableOpenStartDrag?: (direction: 'left' | 'right') => void;\n\n /**\n * Called when action panel starts being shown on dragging to close.\n */\n onSwipeableCloseStartDrag?: (direction: 'left' | 'right') => void;\n\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, +]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderLeftActions?: (\n progressAnimatedValue: SharedValue<number>,\n dragAnimatedValue: SharedValue<number>,\n swipeable: SwipeableMethods\n ) => React.ReactNode;\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, -]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderRightActions?: (\n progressAnimatedValue: SharedValue<number>,\n dragAnimatedValue: SharedValue<number>,\n swipeable: 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 {\n leftThreshold,\n rightThreshold,\n onSwipeableOpenStartDrag,\n onSwipeableCloseStartDrag,\n enableTrackpadTwoFingerGesture,\n enabled,\n containerStyle,\n childrenContainerStyle,\n animationOptions,\n overshootLeft,\n overshootRight,\n onSwipeableWillOpen,\n onSwipeableWillClose,\n onSwipeableOpen,\n onSwipeableClose,\n testID,\n ...remainingProps\n } = props;\n\n const rowState = useSharedValue<number>(0);\n\n const userDrag = useSharedValue<number>(0);\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 const rightOffset = useSharedValue<number>(0);\n\n const leftActionTranslate = useSharedValue<number>(0);\n const rightActionTranslate = useSharedValue<number>(0);\n\n const showLeftProgress = useSharedValue<number>(0);\n const showRightProgress = useSharedValue<number>(0);\n\n const swipeableMethods = useRef<SwipeableMethods>({\n close: () => {\n 'worklet';\n },\n openLeft: () => {\n 'worklet';\n },\n openRight: () => {\n 'worklet';\n },\n reset: () => {\n 'worklet';\n },\n });\n\n const defaultProps = {\n friction: 1,\n overshootFriction: 1,\n };\n\n const {\n friction = defaultProps.friction,\n overshootFriction = defaultProps.overshootFriction,\n } = props;\n\n const overshootLeftProp = overshootLeft;\n const overshootRightProp = overshootRight;\n\n const calculateCurrentOffset = useCallback(() => {\n 'worklet';\n if (rowState.value === 1) {\n return leftWidth.value;\n } else if (rowState.value === -1) {\n return -rowWidth.value - rightOffset.value;\n }\n return 0;\n }, [leftWidth, rightOffset, rowState, rowWidth]);\n\n const updateAnimatedEvent = () => {\n 'worklet';\n rightWidth.value = Math.max(0, rowWidth.value - rightOffset.value);\n\n const overshootLeft = overshootLeftProp ?? leftWidth.value > 0;\n const overshootRight = overshootRightProp ?? 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 - (overshootRight ? 1 / overshootFriction : 0),\n -rightWidth.value,\n leftWidth.value,\n leftWidth.value + (overshootLeft ? 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 leftActionTranslate.value = interpolate(\n showLeftProgress.value,\n [0, Number.MIN_VALUE],\n [-10000, 0],\n Extrapolation.CLAMP\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 rightActionTranslate.value = interpolate(\n showRightProgress.value,\n [0, Number.MIN_VALUE],\n [-10000, 0],\n Extrapolation.CLAMP\n );\n };\n\n const dispatchImmediateEvents = useCallback(\n (fromValue: number, toValue: number) => {\n if (toValue > 0 && onSwipeableWillOpen) {\n onSwipeableWillOpen('left');\n } else if (toValue < 0 && onSwipeableWillOpen) {\n onSwipeableWillOpen('right');\n } else if (onSwipeableWillClose) {\n const closingDirection = fromValue > 0 ? 'left' : 'right';\n onSwipeableWillClose(closingDirection);\n }\n },\n [onSwipeableWillClose, onSwipeableWillOpen]\n );\n\n const dispatchEndEvents = useCallback(\n (fromValue: number, toValue: number) => {\n if (toValue > 0 && onSwipeableOpen) {\n onSwipeableOpen('left', swipeableMethods.current);\n } else if (toValue < 0 && onSwipeableOpen) {\n onSwipeableOpen('right', swipeableMethods.current);\n } else if (onSwipeableClose) {\n const closingDirection = fromValue > 0 ? 'left' : 'right';\n onSwipeableClose(closingDirection, swipeableMethods.current);\n }\n },\n [onSwipeableClose, onSwipeableOpen]\n );\n\n const animationOptionsProp = animationOptions;\n\n const animateRow = useCallback(\n (fromValue: number, toValue: number, velocityX?: number) => {\n 'worklet';\n rowState.value = Math.sign(toValue);\n\n const translationSpringConfig = {\n duration: 1000,\n dampingRatio: 0.9,\n stiffness: 500,\n velocity: velocityX,\n overshootClamping: true,\n ...animationOptionsProp,\n };\n\n const progressSpringConfig = {\n ...translationSpringConfig,\n velocity: 0,\n };\n\n appliedTranslation.value = withSpring(\n toValue,\n translationSpringConfig,\n (isFinished) => {\n if (isFinished) {\n runOnJS(dispatchEndEvents)(fromValue, 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 runOnJS(dispatchImmediateEvents)(fromValue, toValue);\n },\n [\n rowState,\n animationOptionsProp,\n appliedTranslation,\n showLeftProgress,\n leftWidth.value,\n showRightProgress,\n rightWidth.value,\n dispatchImmediateEvents,\n dispatchEndEvents,\n ]\n );\n\n const onRowLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n rowWidth.value = nativeEvent.layout.width;\n };\n\n const {\n children,\n renderLeftActions,\n renderRightActions,\n dragOffsetFromLeftEdge = 10,\n dragOffsetFromRightEdge = 10,\n } = props;\n\n swipeableMethods.current = {\n close() {\n 'worklet';\n animateRow(calculateCurrentOffset(), 0);\n },\n openLeft() {\n 'worklet';\n animateRow(calculateCurrentOffset(), leftWidth.value);\n },\n openRight() {\n 'worklet';\n rightWidth.value = rowWidth.value - rightOffset.value;\n animateRow(calculateCurrentOffset(), -rightWidth.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 const leftAnimatedStyle = useAnimatedStyle(\n () => ({\n transform: [\n {\n translateX: leftActionTranslate.value,\n },\n ],\n }),\n [leftActionTranslate]\n );\n\n const leftElement = renderLeftActions && (\n <Animated.View style={[styles.leftActions, leftAnimatedStyle]}>\n {renderLeftActions(\n showLeftProgress,\n appliedTranslation,\n swipeableMethods.current\n )}\n <View\n onLayout={({ nativeEvent }) =>\n (leftWidth.value = nativeEvent.layout.x)\n }\n />\n </Animated.View>\n );\n\n const rightAnimatedStyle = useAnimatedStyle(\n () => ({\n transform: [\n {\n translateX: rightActionTranslate.value,\n },\n ],\n }),\n [rightActionTranslate]\n );\n\n const rightElement = renderRightActions && (\n <Animated.View style={[styles.rightActions, rightAnimatedStyle]}>\n {renderRightActions(\n showRightProgress,\n appliedTranslation,\n swipeableMethods.current\n )}\n <View\n onLayout={({ nativeEvent }) =>\n (rightOffset.value = nativeEvent.layout.x)\n }\n />\n </Animated.View>\n );\n\n const leftThresholdProp = leftThreshold;\n const rightThresholdProp = rightThreshold;\n\n const handleRelease = (\n event: GestureStateChangeEvent<PanGestureHandlerEventPayload>\n ) => {\n 'worklet';\n const { velocityX } = event;\n userDrag.value = event.translationX;\n\n rightWidth.value = rowWidth.value - rightOffset.value;\n\n const leftThreshold = leftThresholdProp ?? leftWidth.value / 2;\n const rightThreshold = rightThresholdProp ?? rightWidth.value / 2;\n\n const startOffsetX = calculateCurrentOffset() + userDrag.value / friction;\n const translationX = (userDrag.value + DRAG_TOSS * velocityX) / friction;\n\n let toValue = 0;\n\n if (rowState.value === 0) {\n if (translationX > leftThreshold) {\n toValue = leftWidth.value;\n } else if (translationX < -rightThreshold) {\n toValue = -rightWidth.value;\n }\n } else if (rowState.value === 1) {\n // Swiped to left\n if (translationX > -leftThreshold) {\n toValue = leftWidth.value;\n }\n } else {\n // Swiped to right\n if (translationX < rightThreshold) {\n toValue = -rightWidth.value;\n }\n }\n\n animateRow(startOffsetX, toValue, velocityX / friction);\n };\n\n const close = () => {\n 'worklet';\n animateRow(calculateCurrentOffset(), 0);\n };\n\n const tapGesture = Gesture.Tap().onStart(() => {\n if (rowState.value !== 0) {\n close();\n }\n });\n\n const panGesture = Gesture.Pan()\n .onUpdate((event: GestureUpdateEvent<PanGestureHandlerEventPayload>) => {\n userDrag.value = event.translationX;\n\n const direction =\n rowState.value === -1\n ? 'right'\n : rowState.value === 1\n ? 'left'\n : event.translationX > 0\n ? 'left'\n : 'right';\n\n if (rowState.value === 0 && onSwipeableOpenStartDrag) {\n runOnJS(onSwipeableOpenStartDrag)(direction);\n } else if (rowState.value !== 0 && onSwipeableCloseStartDrag) {\n runOnJS(onSwipeableCloseStartDrag)(direction);\n }\n updateAnimatedEvent();\n })\n .onEnd(\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\n handleRelease(event);\n }\n );\n\n if (enableTrackpadTwoFingerGesture) {\n panGesture.enableTrackpadTwoFingerGesture(enableTrackpadTwoFingerGesture);\n }\n\n panGesture.activeOffsetX([\n -dragOffsetFromRightEdge,\n dragOffsetFromLeftEdge,\n ]);\n tapGesture.shouldCancelWhenOutside(true);\n\n useImperativeHandle(ref, () => swipeableMethods.current, [\n swipeableMethods,\n ]);\n\n panGesture.enabled(enabled !== false);\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":["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","Gesture","Tap","shouldCancelWhenOutside","onStart","panGesture","Pan","activeOffsetX","onUpdate","direction","onEnd","onFinalize","animatedStyle","transform","translateX","pointerEvents","swipeableComponent","container","StyleSheet","create","overflow","absoluteFillObject","flexDirection","I18nManager","isRTL"],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d,KAAuB4F,kBAAvB,CADW,GAGXA,kBAHF;AAKD,CAhee,CAAlB;eAmee5G,S;;;AAGf,MAAMiF,MAAM,GAAG6B,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AACTG,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/B9B,EAAAA,WAAW,EAAE,EACX,GAAG4B,wBAAWG,kBADH;AAEXC,IAAAA,aAAa,EAAEC,yBAAYC,KAAZ,GAAoB,aAApB,GAAoC;AAFxC,GAJkB;AAQ/B/B,EAAAA,YAAY,EAAE,EACZ,GAAGyB,wBAAWG,kBADF;AAEZC,IAAAA,aAAa,EAAEC,yBAAYC,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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
var _default = _reactNative.findNodeHandle;
|
|
11
|
+
exports.default = _default;
|
|
12
|
+
//# sourceMappingURL=findNodeHandle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["findNodeHandle.ts"],"names":["findNodeHandle"],"mappings":";;;;;;;AAAA;;eAEeA,2B","sourcesContent":["import { findNodeHandle } from 'react-native';\n\nexport default findNodeHandle;\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = findNodeHandle;
|
|
7
|
+
|
|
8
|
+
var _utils = require("./web/utils");
|
|
9
|
+
|
|
10
|
+
function findNodeHandle(viewRef) {
|
|
11
|
+
// Old API assumes that child handler is HTMLElement.
|
|
12
|
+
// However, if we nest handlers, we will get ref to another handler.
|
|
13
|
+
// In that case, we want to recursively call findNodeHandle with new handler viewTag (which can also be ref to another handler).
|
|
14
|
+
if ((viewRef === null || viewRef === void 0 ? void 0 : viewRef.viewTag) !== undefined) {
|
|
15
|
+
return findNodeHandle(viewRef.viewTag);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (viewRef instanceof Element) {
|
|
19
|
+
if (viewRef.style.display === 'contents') {
|
|
20
|
+
return findNodeHandle(viewRef.firstChild);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return viewRef;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if ((0, _utils.isRNSVGElement)(viewRef)) {
|
|
27
|
+
return viewRef.elementRef.current;
|
|
28
|
+
} // In new API, we receive ref object which `current` field points to wrapper `div` with `display: contents;`.
|
|
29
|
+
// We want to return the first descendant (in DFS order) that doesn't have this property.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
let element = viewRef === null || viewRef === void 0 ? void 0 : viewRef.current;
|
|
33
|
+
|
|
34
|
+
while (element && element.style.display === 'contents') {
|
|
35
|
+
element = element.firstChild;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return element;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=findNodeHandle.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["findNodeHandle.web.ts"],"names":["findNodeHandle","viewRef","viewTag","undefined","Element","style","display","firstChild","elementRef","current","element"],"mappings":";;;;;;;AACA;;AAEe,SAASA,cAAT,CACbC,OADa,EAEsB;AACnC;AACA;AACA;AACA,MAAI,CAACA,OAAD,aAACA,OAAD,uBAACA,OAAD,CAAgCC,OAAhC,MAA4CC,SAAhD,EAA2D;AACzD,WAAOH,cAAc,CAAEC,OAAD,CAA+BC,OAAhC,CAArB;AACD;;AAED,MAAID,OAAO,YAAYG,OAAvB,EAAgC;AAC9B,QAAIH,OAAO,CAACI,KAAR,CAAcC,OAAd,KAA0B,UAA9B,EAA0C;AACxC,aAAON,cAAc,CAACC,OAAO,CAACM,UAAT,CAArB;AACD;;AAED,WAAON,OAAP;AACD;;AAED,MAAI,2BAAeA,OAAf,CAAJ,EAA6B;AAC3B,WAAQA,OAAD,CAAoBO,UAApB,CAA+BC,OAAtC;AACD,GAlBkC,CAoBnC;AACA;;;AACA,MAAIC,OAAO,GAAIT,OAAJ,aAAIA,OAAJ,uBAAIA,OAAD,CAAgCQ,OAA9C;;AAEA,SAAOC,OAAO,IAAIA,OAAO,CAACL,KAAR,CAAcC,OAAd,KAA0B,UAA5C,EAAwD;AACtDI,IAAAA,OAAO,GAAGA,OAAO,CAACH,UAAlB;AACD;;AAED,SAAOG,OAAP;AACD","sourcesContent":["import type { GestureHandlerRef, SVGRef } from './web/interfaces';\nimport { isRNSVGElement } from './web/utils';\n\nexport default function findNodeHandle(\n viewRef: GestureHandlerRef | SVGRef | HTMLElement | SVGElement\n): HTMLElement | SVGElement | number {\n // Old API assumes that child handler is HTMLElement.\n // However, if we nest handlers, we will get ref to another handler.\n // In that case, we want to recursively call findNodeHandle with new handler viewTag (which can also be ref to another handler).\n if ((viewRef as GestureHandlerRef)?.viewTag !== undefined) {\n return findNodeHandle((viewRef as GestureHandlerRef).viewTag);\n }\n\n if (viewRef instanceof Element) {\n if (viewRef.style.display === 'contents') {\n return findNodeHandle(viewRef.firstChild as HTMLElement);\n }\n\n return viewRef;\n }\n\n if (isRNSVGElement(viewRef)) {\n return (viewRef as SVGRef).elementRef.current;\n }\n\n // In new API, we receive ref object which `current` field points to wrapper `div` with `display: contents;`.\n // We want to return the first descendant (in DFS order) that doesn't have this property.\n let element = (viewRef as GestureHandlerRef)?.current;\n\n while (element && element.style.display === 'contents') {\n element = element.firstChild as HTMLElement;\n }\n\n return element;\n}\n"]}
|