react-native-reorderable-list 0.8.0 → 0.10.0
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/README.md +104 -32
- package/lib/commonjs/components/ReorderableListCell.js +19 -14
- package/lib/commonjs/components/ReorderableListCell.js.map +1 -1
- package/lib/commonjs/components/ReorderableListCore/ReorderableListCore.js +11 -11
- package/lib/commonjs/components/ReorderableListCore/ReorderableListCore.js.map +1 -1
- package/lib/commonjs/components/ReorderableListCore/useReorderableListCore.js +50 -22
- package/lib/commonjs/components/ReorderableListCore/useReorderableListCore.js.map +1 -1
- package/lib/commonjs/components/helpers.js +32 -0
- package/lib/commonjs/components/helpers.js.map +1 -0
- package/lib/commonjs/contexts/ReorderableCellContext.js.map +1 -1
- package/lib/commonjs/contexts/ReorderableListContext.js.map +1 -1
- package/lib/commonjs/hooks/index.js +11 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useIsActive.js +16 -0
- package/lib/commonjs/hooks/useIsActive.js.map +1 -0
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/misc.js.map +1 -1
- package/lib/module/components/ReorderableListCell.js +19 -14
- package/lib/module/components/ReorderableListCell.js.map +1 -1
- package/lib/module/components/ReorderableListCore/ReorderableListCore.js +11 -11
- package/lib/module/components/ReorderableListCore/ReorderableListCore.js.map +1 -1
- package/lib/module/components/ReorderableListCore/useReorderableListCore.js +51 -23
- package/lib/module/components/ReorderableListCore/useReorderableListCore.js.map +1 -1
- package/lib/module/components/helpers.js +25 -0
- package/lib/module/components/helpers.js.map +1 -0
- package/lib/module/contexts/ReorderableCellContext.js.map +1 -1
- package/lib/module/contexts/ReorderableListContext.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useIsActive.js +9 -0
- package/lib/module/hooks/useIsActive.js.map +1 -0
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/misc.js.map +1 -1
- package/lib/typescript/components/ReorderableListCell.d.ts.map +1 -1
- package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts +138 -3
- package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts.map +1 -1
- package/lib/typescript/components/helpers.d.ts +11 -0
- package/lib/typescript/components/helpers.d.ts.map +1 -0
- package/lib/typescript/contexts/ReorderableCellContext.d.ts +1 -0
- package/lib/typescript/contexts/ReorderableCellContext.d.ts.map +1 -1
- package/lib/typescript/contexts/ReorderableListContext.d.ts +3 -2
- package/lib/typescript/contexts/ReorderableListContext.d.ts.map +1 -1
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/index.d.ts.map +1 -1
- package/lib/typescript/hooks/useIsActive.d.ts +2 -0
- package/lib/typescript/hooks/useIsActive.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/misc.d.ts +9 -0
- package/lib/typescript/types/misc.d.ts.map +1 -1
- package/lib/typescript/types/props.d.ts +35 -8
- package/lib/typescript/types/props.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/components/ReorderableListCell.tsx +24 -11
- package/src/components/ReorderableListCore/ReorderableListCore.tsx +9 -9
- package/src/components/ReorderableListCore/useReorderableListCore.ts +68 -20
- package/src/components/helpers.ts +36 -0
- package/src/contexts/ReorderableCellContext.ts +1 -0
- package/src/contexts/ReorderableListContext.ts +4 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useIsActive.ts +7 -0
- package/src/index.ts +2 -0
- package/src/types/misc.ts +10 -0
- package/src/types/props.ts +71 -8
package/README.md
CHANGED
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
A reorderable list for React Native applications, powered by Reanimated 🚀
|
|
11
11
|
|
|
12
|
-

|
|
12
|
+

|
|
14
13
|
|
|
15
14
|
## Index
|
|
16
15
|
|
|
@@ -23,7 +22,10 @@ A reorderable list for React Native applications, powered by Reanimated 🚀
|
|
|
23
22
|
- [useReorderableDrag](#usereorderabledrag)
|
|
24
23
|
- [useReorderableDragStart](#usereorderabledragstart)
|
|
25
24
|
- [useReorderableDragEnd](#usereorderabledragend)
|
|
25
|
+
- [useIsActive](#useisactive)
|
|
26
26
|
- [Utils](#utils)
|
|
27
|
+
- [Troubleshooting](#troubleshooting)
|
|
28
|
+
- [RefreshControl](#refreshcontrol)
|
|
27
29
|
- [Example](#example)
|
|
28
30
|
- [License](#license)
|
|
29
31
|
|
|
@@ -54,18 +56,22 @@ Then you need to install these two peer dependencies:
|
|
|
54
56
|
|
|
55
57
|
This component uses a [FlatList](https://reactnative.dev/docs/flatlist) and it extends its props:
|
|
56
58
|
|
|
57
|
-
| Props
|
|
58
|
-
|
|
|
59
|
-
| autoscrollThreshold
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
59
|
+
| Props | Type | Required | Default | Description |
|
|
60
|
+
| ------------------------- | ------------------------------------------------ | -------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
61
|
+
| autoscrollThreshold | `number` | No | `0.1` | Threshold at the extremity of the list that triggers autoscroll when an item is dragged to it. A value of `0.1` means that 10% of the area at the top and 10% at the bottom will trigger autoscroll. Min value: `0`. Max value: `0.4`. |
|
|
62
|
+
| autoscrollThresholdOffset | `{top?: number; bottom?: number}` | No | `{top: 0, bottom: 0}` | Amount by which the threshold is offset at the extremety of the list. For example, setting `{top: 50}` will make the autoscroll trigger 50 pixels earlier at the top. |
|
|
63
|
+
| autoscrollSpeedScale | `number` | No | `1` | Scales the autoscroll speed at which the list scrolls when an item is dragged to the scroll areas. |
|
|
64
|
+
| autoscrollDelay | `number` | No | `0` (Android), `100` (iOS) | Delay in between autoscroll triggers. Can be used to tune the autoscroll smoothness. Default values differ between platforms: `0` for Android and `100` for iOS. |
|
|
65
|
+
| dragReorderThreshold | `number` | No | `0.2` | Specifies the fraction of an item's size at which it will shift when a dragged item crosses over it. For example, `0.2` means the item shifts when the dragged item passes 20% of its height (in a vertical list). |
|
|
66
|
+
| animationDuration | `number` | No | `200` | Duration of the animations in milliseconds. Users won't be able to drag a new item until the dragged item is released and its animation to its new position ends. |
|
|
67
|
+
| cellAnimations | `ReorderableListCellAnimations` | No | N/A | Allows passing an object with values and/or shared values that can animate a cell, for example by using the `onDragStart` and `onDragEnd` events. Supports view style properties. Override opacity and/or transform to disable the default animation, e.g. `{opacity: 1, transform: []}`. Check the [examples](https://github.com/omahili/react-native-reorderable-list/tree/master/example) for more details. |
|
|
68
|
+
| shouldUpdateActiveItem | boolean | No | `false` | Whether the active item should be updated. Enables usage of `useIsActive` hook. |
|
|
69
|
+
| panEnabled | `boolean` | No | `true` | Wether the pan gestures necessary for dragging are enabled. |
|
|
70
|
+
| panActivateAfterLongPress | `number` | No | N/A | Duration in milliseconds a the long press on the list before pan gestures, necessary for dragging, are allowed to activate. |
|
|
71
|
+
| onReorder | `(event: { from: number, to: number }) => void` | Yes | N/A | Event fired after an item is released and the list is reordered. |
|
|
72
|
+
| onDragStart | `(event: { index: number }) => void` | No | N/A | Event fired when an item is dragged. Needs to be a `worklet`. See [Reanimated docs](https://docs.swmansion.com/react-native-reanimated) for further info. |
|
|
73
|
+
| onDragEnd | `(event: { from: number, to: number }) => void` | No | N/A | Event fired when the dragged item is released. Needs to be a `worklet`. See [Reanimated docs](https://docs.swmansion.com/react-native-reanimated) for further info. |
|
|
74
|
+
| onScroll | `ReturnType<typeof useAnimatedScrollHandler>` | No | N/A | An animated scroll handler created with useAnimatedScrollHandler. See [Reanimated docs](https://docs.swmansion.com/react-native-reanimated) for further info. |
|
|
69
75
|
|
|
70
76
|
The following props from FlatList are not supported:
|
|
71
77
|
|
|
@@ -133,19 +139,90 @@ useReorderableDragEnd(
|
|
|
133
139
|
|
|
134
140
|
Using this hook in large lists is discouraged due to performance bottlenecks, prefer `onDragEnd` on the ReorderableList instead.
|
|
135
141
|
|
|
142
|
+
### useIsActive
|
|
143
|
+
|
|
144
|
+
This hook returns a boolean indicating whether the current item is active. It will return true on drag start and false on drag end. This hook can only be used inside of a list item component.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const isActive = useIsActive();
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Additionally this hook requires setting `shouldUpdateActiveItem` to true on the ReorderableList:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
<ReorderableList
|
|
154
|
+
// ...
|
|
155
|
+
shouldUpdateActiveItem
|
|
156
|
+
/>
|
|
157
|
+
```
|
|
158
|
+
|
|
136
159
|
## Utils
|
|
137
160
|
|
|
138
161
|
- **reorderItems**: `<T>(data: T[], from: number, to: number) => T[]`
|
|
139
162
|
|
|
140
163
|
This function receives an array of items, the index of the item to be moved, and the index of the new position and it returns a new array with the items reordered.
|
|
141
164
|
|
|
165
|
+
## Troubleshooting
|
|
166
|
+
|
|
167
|
+
### RefreshControl
|
|
168
|
+
|
|
169
|
+
If you want to use RefreshControl with ReorderableList you might encounter some issues on Android, where gestures are conflicting making one or both of the components non responsive. To overcome this issues you can delay the activation of pan gestures necessary for dragging items by using the `panActivateAfterLongPress` prop. This duration should be slightly longer than the long press delay necessary to drag your items. If you're using Pressable the `delayLongPress` is 500 ms by default.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
<ReorderableList
|
|
173
|
+
// ...
|
|
174
|
+
panActivateAfterLongPress={Platform.OS === 'android' ? 520 : undefined}
|
|
175
|
+
/>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
If you change `delayLongPress` on your Pressable, update this prop accordingly.
|
|
179
|
+
|
|
180
|
+
Another issue you'll encounter is that when you drag your items the RefreshControl might animate. To avoid this you can enable and disable it on drag start and drag end like so:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const [refreshEnabled, setRefreshEnabled] = useState(true);
|
|
184
|
+
|
|
185
|
+
const handleDragStart = useCallback(() => {
|
|
186
|
+
'worklet';
|
|
187
|
+
|
|
188
|
+
// NOTE: If it's refreshing we don't want the refresh control to disappear
|
|
189
|
+
// and we can keep it enabled since it won't conflict with the drag.
|
|
190
|
+
if (Platform.OS === 'android' && !refreshing) {
|
|
191
|
+
runOnJS(setRefreshEnabled)(false);
|
|
192
|
+
}
|
|
193
|
+
}, [refreshing]);
|
|
194
|
+
|
|
195
|
+
const handleDragEnd = useCallback(() => {
|
|
196
|
+
'worklet';
|
|
197
|
+
|
|
198
|
+
if (Platform.OS === 'android') {
|
|
199
|
+
runOnJS(setRefreshEnabled)(true);
|
|
200
|
+
}
|
|
201
|
+
}, []);
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<ReorderableList
|
|
205
|
+
// ...
|
|
206
|
+
onDragStart={handleDragStart}
|
|
207
|
+
onDragEnd={handleDragEnd}
|
|
208
|
+
refreshControl={
|
|
209
|
+
<RefreshControl
|
|
210
|
+
// ...
|
|
211
|
+
enabled={refreshEnabled}
|
|
212
|
+
/>
|
|
213
|
+
}
|
|
214
|
+
/>
|
|
215
|
+
);
|
|
216
|
+
```
|
|
217
|
+
|
|
142
218
|
## Example
|
|
143
219
|
|
|
144
|
-
Here is simple example of how to use this component. Examples of nested lists and much more can be found in the [example](https://github.com/omahili/react-native-reorderable-list/tree/
|
|
220
|
+
Here is simple example of how to use this component. Examples of nested lists and much more can be found in the [example](https://github.com/omahili/react-native-reorderable-list/tree/master/example) directory.
|
|
145
221
|
|
|
146
222
|
```typescript
|
|
147
223
|
import React, {memo, useState} from 'react';
|
|
148
224
|
import {ListRenderItemInfo, Pressable, StyleSheet, Text} from 'react-native';
|
|
225
|
+
|
|
149
226
|
import ReorderableList, {
|
|
150
227
|
ReorderableListReorderEvent,
|
|
151
228
|
reorderItems,
|
|
@@ -158,18 +235,15 @@ interface CardProps {
|
|
|
158
235
|
height: number;
|
|
159
236
|
}
|
|
160
237
|
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
{id: '8', color: 'crimson', height: 90},
|
|
171
|
-
{id: '9', color: 'seagreen', height: 90},
|
|
172
|
-
];
|
|
238
|
+
const rand = () => Math.floor(Math.random() * 256);
|
|
239
|
+
|
|
240
|
+
const seedData: CardProps[] = Array(20)
|
|
241
|
+
.fill(null)
|
|
242
|
+
.map((_, i) => ({
|
|
243
|
+
id: i.toString(),
|
|
244
|
+
color: `rgb(${rand()}, ${rand()}, ${rand()})`,
|
|
245
|
+
height: Math.max(60, Math.floor(Math.random() * 100)),
|
|
246
|
+
}));
|
|
173
247
|
|
|
174
248
|
const Card: React.FC<CardProps> = memo(({id, color, height}) => {
|
|
175
249
|
const drag = useReorderableDrag();
|
|
@@ -182,7 +256,7 @@ const Card: React.FC<CardProps> = memo(({id, color, height}) => {
|
|
|
182
256
|
});
|
|
183
257
|
|
|
184
258
|
const Example = () => {
|
|
185
|
-
const [data, setData] = useState(
|
|
259
|
+
const [data, setData] = useState(seedData);
|
|
186
260
|
|
|
187
261
|
const handleReorder = ({from, to}: ReorderableListReorderEvent) => {
|
|
188
262
|
setData(value => reorderItems(value, from, to));
|
|
@@ -206,11 +280,9 @@ const styles = StyleSheet.create({
|
|
|
206
280
|
card: {
|
|
207
281
|
justifyContent: 'center',
|
|
208
282
|
alignItems: 'center',
|
|
209
|
-
margin: 6,
|
|
210
|
-
borderRadius: 5,
|
|
211
283
|
backgroundColor: 'white',
|
|
212
|
-
|
|
213
|
-
|
|
284
|
+
borderBottomWidth: 1,
|
|
285
|
+
borderBottomColor: '#ddd',
|
|
214
286
|
},
|
|
215
287
|
text: {
|
|
216
288
|
fontSize: 20,
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
9
9
|
var _contexts = require("../contexts");
|
|
10
10
|
var _hooks = require("../hooks");
|
|
11
|
+
var _helpers = require("./helpers");
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
14
|
const ReorderableListCell = exports.ReorderableListCell = /*#__PURE__*/(0, _react.memo)(({
|
|
@@ -24,21 +25,23 @@ const ReorderableListCell = exports.ReorderableListCell = /*#__PURE__*/(0, _reac
|
|
|
24
25
|
const {
|
|
25
26
|
currentIndex,
|
|
26
27
|
draggedHeight,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
activeIndex,
|
|
29
|
+
cellAnimations
|
|
29
30
|
} = (0, _hooks.useContext)(_contexts.ReorderableListContext);
|
|
30
31
|
const dragHandler = (0, _react.useCallback)(() => (0, _reactNativeReanimated.runOnUI)(startDrag)(index), [startDrag, index]);
|
|
32
|
+
const isActive = activeIndex === index;
|
|
31
33
|
const contextValue = (0, _react.useMemo)(() => ({
|
|
32
34
|
index,
|
|
33
35
|
dragHandler,
|
|
34
|
-
draggedIndex
|
|
35
|
-
|
|
36
|
+
draggedIndex,
|
|
37
|
+
isActive
|
|
38
|
+
}), [index, dragHandler, draggedIndex, isActive]);
|
|
36
39
|
|
|
37
40
|
// Keep separate animated reactions that update itemTranslateY
|
|
38
41
|
// otherwise animations might stutter if multiple are triggered
|
|
39
42
|
// (even in other cells, e.g. released item and reordering cells)
|
|
40
43
|
const itemTranslateY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
41
|
-
const
|
|
44
|
+
const isActiveCell = (0, _reactNativeReanimated.useDerivedValue)(() => draggedIndex.value === index);
|
|
42
45
|
(0, _reactNativeReanimated.useAnimatedReaction)(() => dragY.value, () => {
|
|
43
46
|
if (index === draggedIndex.value && currentIndex.value >= 0 && draggedIndex.value >= 0) {
|
|
44
47
|
itemTranslateY.value = dragY.value;
|
|
@@ -62,16 +65,18 @@ const ReorderableListCell = exports.ReorderableListCell = /*#__PURE__*/(0, _reac
|
|
|
62
65
|
}
|
|
63
66
|
});
|
|
64
67
|
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
if (isActiveCell.value) {
|
|
69
|
+
const transform = [{
|
|
70
|
+
translateY: itemTranslateY.value
|
|
71
|
+
}];
|
|
72
|
+
if (Array.isArray(cellAnimations.transform)) {
|
|
73
|
+
const customTransform = cellAnimations.transform.map(x => (0, _helpers.applyAnimatedStyles)({}, x));
|
|
74
|
+
transform.push(...customTransform);
|
|
75
|
+
}
|
|
76
|
+
return (0, _helpers.applyAnimatedStyles)({
|
|
77
|
+
transform,
|
|
73
78
|
zIndex: 999
|
|
74
|
-
};
|
|
79
|
+
}, cellAnimations, ['transform']);
|
|
75
80
|
}
|
|
76
81
|
return {
|
|
77
82
|
transform: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_contexts","_hooks","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ReorderableListCell","exports","memo","index","startDrag","children","onLayout","itemOffset","itemHeight","dragY","draggedIndex","animationDuration","currentIndex","draggedHeight","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_contexts","_hooks","_helpers","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ReorderableListCell","exports","memo","index","startDrag","children","onLayout","itemOffset","itemHeight","dragY","draggedIndex","animationDuration","currentIndex","draggedHeight","activeIndex","cellAnimations","useContext","ReorderableListContext","dragHandler","useCallback","runOnUI","isActive","contextValue","useMemo","itemTranslateY","useSharedValue","isActiveCell","useDerivedValue","value","useAnimatedReaction","moveDown","startMove","Math","min","endMove","max","newValue","withTiming","duration","easing","Easing","out","ease","animatedStyle","useAnimatedStyle","transform","translateY","Array","isArray","customTransform","map","x","applyAnimatedStyles","push","zIndex","handleLayout","y","height","nativeEvent","layout","createElement","ReorderableCellContext","Provider","View","style"],"sourceRoot":"../../../src","sources":["components/ReorderableListCell.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,sBAAA,GAAAF,uBAAA,CAAAC,OAAA;AAWA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAA8C,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,e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U,CAACqB,KAAK,CAACzB,KAAK,CAAC,GAAGqD,CAAC;MAC3BhD,UAAU,CAACoB,KAAK,CAACzB,KAAK,CAAC,GAAGsD,MAAM;IAClC,CAAC,CAAC,CAAC5E,CAAC,CAAC6E,WAAW,CAACC,MAAM,CAACH,CAAC,EAAE3E,CAAC,CAAC6E,WAAW,CAACC,MAAM,CAACF,MAAM,CAAC;IAEvDnD,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAGzB,CAAC,CAAC;EACf,CAAC;EAED,oBACER,MAAA,CAAAa,OAAA,CAAA0E,aAAA,CAACnF,SAAA,CAAAoF,sBAAsB,CAACC,QAAQ;IAAClC,KAAK,EAAEN;EAAa,gBACnDjD,MAAA,CAAAa,OAAA,CAAA0E,aAAA,CAACpF,sBAAA,CAAAU,OAAQ,CAAC6E,IAAI;IAACC,KAAK,EAAErB,aAAc;IAACrC,QAAQ,EAAEiD;EAAa,GACzDlD,QACY,CACgB,CAAC;AAEtC,CACF,CAAC","ignoreList":[]}
|
|
@@ -17,8 +17,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
17
17
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
18
18
|
const AnimatedFlatList = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.FlatList);
|
|
19
19
|
const ReorderableListCore = ({
|
|
20
|
-
data,
|
|
21
20
|
autoscrollThreshold = 0.1,
|
|
21
|
+
autoscrollThresholdOffset,
|
|
22
22
|
autoscrollSpeedScale = 1,
|
|
23
23
|
autoscrollDelay = _autoscrollConfig.AUTOSCROLL_CONFIG.delay,
|
|
24
24
|
animationDuration = 200,
|
|
@@ -28,17 +28,17 @@ const ReorderableListCore = ({
|
|
|
28
28
|
onScroll,
|
|
29
29
|
onDragStart,
|
|
30
30
|
onDragEnd,
|
|
31
|
-
keyExtractor,
|
|
32
|
-
extraData,
|
|
33
31
|
scrollViewContainerRef,
|
|
34
32
|
scrollViewHeightY,
|
|
35
33
|
scrollViewScrollOffsetY,
|
|
36
34
|
scrollViewScrollEnabled,
|
|
37
|
-
scrollEnabled,
|
|
38
35
|
initialScrollViewScrollEnabled,
|
|
39
36
|
scrollable,
|
|
40
37
|
outerScrollGesture,
|
|
41
38
|
cellAnimations,
|
|
39
|
+
shouldUpdateActiveItem,
|
|
40
|
+
panEnabled = true,
|
|
41
|
+
panActivateAfterLongPress,
|
|
42
42
|
...rest
|
|
43
43
|
}, ref) => {
|
|
44
44
|
const {
|
|
@@ -56,6 +56,7 @@ const ReorderableListCore = ({
|
|
|
56
56
|
} = (0, _useReorderableListCore.useReorderableListCore)({
|
|
57
57
|
ref,
|
|
58
58
|
autoscrollThreshold,
|
|
59
|
+
autoscrollThresholdOffset,
|
|
59
60
|
autoscrollSpeedScale,
|
|
60
61
|
autoscrollDelay,
|
|
61
62
|
animationDuration,
|
|
@@ -70,10 +71,13 @@ const ReorderableListCore = ({
|
|
|
70
71
|
scrollViewScrollEnabled,
|
|
71
72
|
// flatlist will default to true if we pass explicitly undefined,
|
|
72
73
|
// but internally we would treat it as false, so we force true
|
|
73
|
-
initialScrollEnabled: typeof scrollEnabled === 'undefined' ? true : scrollEnabled,
|
|
74
|
+
initialScrollEnabled: typeof rest.scrollEnabled === 'undefined' ? true : rest.scrollEnabled,
|
|
74
75
|
initialScrollViewScrollEnabled: typeof initialScrollViewScrollEnabled === 'undefined' ? true : initialScrollViewScrollEnabled,
|
|
75
76
|
nestedScrollable: scrollable,
|
|
76
|
-
cellAnimations
|
|
77
|
+
cellAnimations,
|
|
78
|
+
shouldUpdateActiveItem,
|
|
79
|
+
panEnabled,
|
|
80
|
+
panActivateAfterLongPress
|
|
77
81
|
});
|
|
78
82
|
const combinedGesture = (0, _react.useMemo)(() => {
|
|
79
83
|
// android is able to handle nested scroll view, but not the full height ones like iOS
|
|
@@ -102,17 +106,13 @@ const ReorderableListCore = ({
|
|
|
102
106
|
gesture: combinedGesture
|
|
103
107
|
}, /*#__PURE__*/_react.default.createElement(AnimatedFlatList, _extends({}, rest, {
|
|
104
108
|
ref: handleRef,
|
|
105
|
-
data: data,
|
|
106
109
|
CellRendererComponent: renderAnimatedCell,
|
|
107
110
|
onLayout: handleFlatListLayout,
|
|
108
111
|
onScroll: composedScrollHandler,
|
|
109
112
|
scrollEventThrottle: 1,
|
|
110
113
|
horizontal: false,
|
|
111
114
|
removeClippedSubviews: false,
|
|
112
|
-
|
|
113
|
-
extraData: extraData,
|
|
114
|
-
numColumns: 1,
|
|
115
|
-
scrollEnabled: scrollEnabled
|
|
115
|
+
numColumns: 1
|
|
116
116
|
}))));
|
|
117
117
|
};
|
|
118
118
|
const MemoizedReorderableListCore = exports.ReorderableListCore = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef(ReorderableListCore));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeGestureHandler","_reactNativeReanimated","_autoscrollConfig","_useReorderableListCore","_contexts","_ReorderableListCell","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","AnimatedFlatList","Animated","createAnimatedComponent","FlatList","ReorderableListCore","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeGestureHandler","_reactNativeReanimated","_autoscrollConfig","_useReorderableListCore","_contexts","_ReorderableListCell","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","AnimatedFlatList","Animated","createAnimatedComponent","FlatList","ReorderableListCore","autoscrollThreshold","autoscrollThresholdOffset","autoscrollSpeedScale","autoscrollDelay","AUTOSCROLL_CONFIG","delay","animationDuration","dragReorderThreshold","onLayout","onReorder","onScroll","onDragStart","onDragEnd","scrollViewContainerRef","scrollViewHeightY","scrollViewScrollOffsetY","scrollViewScrollEnabled","initialScrollViewScrollEnabled","scrollable","outerScrollGesture","cellAnimations","shouldUpdateActiveItem","panEnabled","panActivateAfterLongPress","rest","ref","gestureHandler","handleScroll","handleFlatListLayout","handleRef","startDrag","listContextValue","itemOffset","itemHeight","dragY","draggedIndex","duration","useReorderableListCore","initialScrollEnabled","scrollEnabled","nestedScrollable","combinedGesture","useMemo","Platform","OS","Gesture","Simultaneous","composedScrollHandler","useComposedEventHandler","renderAnimatedCell","useCallback","cellKey","props","createElement","ReorderableListCell","key","index","ReorderableListContext","Provider","value","GestureDetector","gesture","CellRendererComponent","scrollEventThrottle","horizontal","removeClippedSubviews","numColumns","MemoizedReorderableListCore","exports","React","memo","forwardRef"],"sourceRoot":"../../../../src","sources":["components/ReorderableListCore/ReorderableListCore.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,0BAAA,GAAAF,OAAA;AAKA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAKA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEA,IAAAO,oBAAA,GAAAP,OAAA;AAA2D,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ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AA,KACXmC,IAAI;IACRC,GAAG,EAAEI,SAAU;IACfiC,qBAAqB,EAAEb,kBAAmB;IAC1CzC,QAAQ,EAAEoB,oBAAqB;IAC/BlB,QAAQ,EAAEqC,qBAAsB;IAChCgB,mBAAmB,EAAE,CAAE;IACvBC,UAAU,EAAE,KAAM;IAClBC,qBAAqB,EAAE,KAAM;IAC7BC,UAAU,EAAE;EAAE,EACf,CACc,CACc,CAAC;AAEtC,CAAC;AAED,MAAMC,2BAA2B,GAAAC,OAAA,CAAArE,mBAAA,gBAAGsE,cAAK,CAACC,IAAI,cAC5CD,cAAK,CAACE,UAAU,CAACxE,mBAAmB,CACtC,CAIuB","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ const hasAutomaticBatching = version.length ? parseInt(version[0], 10) >= 18 : f
|
|
|
18
18
|
const useReorderableListCore = ({
|
|
19
19
|
ref,
|
|
20
20
|
autoscrollThreshold,
|
|
21
|
+
autoscrollThresholdOffset,
|
|
21
22
|
autoscrollSpeedScale,
|
|
22
23
|
autoscrollDelay,
|
|
23
24
|
animationDuration,
|
|
@@ -33,9 +34,13 @@ const useReorderableListCore = ({
|
|
|
33
34
|
initialScrollEnabled,
|
|
34
35
|
initialScrollViewScrollEnabled,
|
|
35
36
|
nestedScrollable,
|
|
36
|
-
cellAnimations
|
|
37
|
+
cellAnimations,
|
|
38
|
+
shouldUpdateActiveItem,
|
|
39
|
+
panActivateAfterLongPress,
|
|
40
|
+
panEnabled
|
|
37
41
|
}) => {
|
|
38
42
|
const flatListRef = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
43
|
+
const [activeIndex, setActiveIndex] = (0, _react.useState)(-1);
|
|
39
44
|
const scrollEnabled = (0, _reactNativeReanimated.useSharedValue)(initialScrollEnabled);
|
|
40
45
|
const gestureState = (0, _reactNativeReanimated.useSharedValue)(_reactNativeGestureHandler.State.UNDETERMINED);
|
|
41
46
|
const currentY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
@@ -64,10 +69,6 @@ const useReorderableListCore = ({
|
|
|
64
69
|
const duration = (0, _reactNativeReanimated.useSharedValue)(animationDuration);
|
|
65
70
|
const scaleDefault = (0, _reactNativeReanimated.useSharedValue)(1);
|
|
66
71
|
const opacityDefault = (0, _reactNativeReanimated.useSharedValue)(1);
|
|
67
|
-
const {
|
|
68
|
-
scale,
|
|
69
|
-
opacity
|
|
70
|
-
} = cellAnimations || {};
|
|
71
72
|
(0, _react.useEffect)(() => {
|
|
72
73
|
duration.value = animationDuration;
|
|
73
74
|
}, [duration, animationDuration]);
|
|
@@ -76,9 +77,15 @@ const useReorderableListCore = ({
|
|
|
76
77
|
currentIndex,
|
|
77
78
|
draggedIndex,
|
|
78
79
|
dragEndHandlers,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
activeIndex,
|
|
81
|
+
cellAnimations: {
|
|
82
|
+
...cellAnimations,
|
|
83
|
+
transform: cellAnimations && 'transform' in cellAnimations ? cellAnimations.transform : [{
|
|
84
|
+
scale: scaleDefault
|
|
85
|
+
}],
|
|
86
|
+
opacity: cellAnimations && 'opacity' in cellAnimations ? cellAnimations.opacity : opacityDefault
|
|
87
|
+
}
|
|
88
|
+
}), [draggedHeight, currentIndex, draggedIndex, dragEndHandlers, activeIndex, cellAnimations, scaleDefault, opacityDefault]);
|
|
82
89
|
const panGestureHandler = (0, _react.useMemo)(() => _reactNativeGestureHandler.Gesture.Pan().onBegin(e => {
|
|
83
90
|
// prevent new dragging until item is completely released
|
|
84
91
|
if (state.value === _types.ReorderableListState.IDLE) {
|
|
@@ -96,7 +103,16 @@ const useReorderableListCore = ({
|
|
|
96
103
|
gestureState.value = e.state;
|
|
97
104
|
}
|
|
98
105
|
}).onEnd(e => gestureState.value = e.state).onFinalize(e => gestureState.value = e.state), [currentTranslationY, currentY, dragScrollTranslationY, scrollViewDragScrollTranslationY, gestureState, dragY, startY, state]);
|
|
99
|
-
const
|
|
106
|
+
const panGestureHandlerWithOptions = (0, _react.useMemo)(() => {
|
|
107
|
+
if (typeof panActivateAfterLongPress === 'number') {
|
|
108
|
+
panGestureHandler.activateAfterLongPress(panActivateAfterLongPress);
|
|
109
|
+
}
|
|
110
|
+
if (!panEnabled) {
|
|
111
|
+
panGestureHandler.enabled(panEnabled);
|
|
112
|
+
}
|
|
113
|
+
return panGestureHandler;
|
|
114
|
+
}, [panActivateAfterLongPress, panEnabled, panGestureHandler]);
|
|
115
|
+
const gestureHandler = (0, _react.useMemo)(() => _reactNativeGestureHandler.Gesture.Simultaneous(_reactNativeGestureHandler.Gesture.Native(), panGestureHandlerWithOptions), [panGestureHandlerWithOptions]);
|
|
100
116
|
const setScrollEnabled = (0, _react.useCallback)(enabled => {
|
|
101
117
|
// if scroll is enabled on list props then we can toggle it
|
|
102
118
|
if (initialScrollEnabled) {
|
|
@@ -198,24 +214,27 @@ const useReorderableListCore = ({
|
|
|
198
214
|
const runDefaultDragAnimations = (0, _react.useCallback)(type => {
|
|
199
215
|
'worklet';
|
|
200
216
|
|
|
201
|
-
// if
|
|
202
|
-
if (
|
|
217
|
+
// if no custom scale run default
|
|
218
|
+
if (!(cellAnimations && 'transformtra' in cellAnimations)) {
|
|
203
219
|
const scaleConfig = _animationDefaults.SCALE_ANIMATION_CONFIG_DEFAULT[type];
|
|
204
220
|
scaleDefault.value = (0, _reactNativeReanimated.withTiming)(scaleConfig.toValue, scaleConfig);
|
|
205
221
|
}
|
|
206
222
|
|
|
207
|
-
// if
|
|
208
|
-
if (
|
|
223
|
+
// if no custom opacity run the default
|
|
224
|
+
if (!(cellAnimations && 'opacity' in cellAnimations)) {
|
|
209
225
|
const opacityConfig = _animationDefaults.OPACITY_ANIMATION_CONFIG_DEFAULT[type];
|
|
210
226
|
opacityDefault.value = (0, _reactNativeReanimated.withTiming)(opacityConfig.toValue, opacityConfig);
|
|
211
227
|
}
|
|
212
|
-
}, [
|
|
228
|
+
}, [cellAnimations, scaleDefault, opacityDefault]);
|
|
213
229
|
(0, _reactNativeReanimated.useAnimatedReaction)(() => gestureState.value, () => {
|
|
214
230
|
if (gestureState.value !== _reactNativeGestureHandler.State.ACTIVE && gestureState.value !== _reactNativeGestureHandler.State.BEGAN && (state.value === _types.ReorderableListState.DRAGGED || state.value === _types.ReorderableListState.AUTOSCROLL)) {
|
|
215
231
|
state.value = _types.ReorderableListState.RELEASED;
|
|
216
232
|
|
|
217
233
|
// enable back scroll on releasing
|
|
218
234
|
(0, _reactNativeReanimated.runOnJS)(setScrollEnabled)(true);
|
|
235
|
+
if (shouldUpdateActiveItem) {
|
|
236
|
+
(0, _reactNativeReanimated.runOnJS)(setActiveIndex)(-1);
|
|
237
|
+
}
|
|
219
238
|
|
|
220
239
|
// trigger onDragEnd event
|
|
221
240
|
let e = {
|
|
@@ -272,21 +291,27 @@ const useReorderableListCore = ({
|
|
|
272
291
|
const calculateThresholdArea = (0, _react.useCallback)(hiddenArea => {
|
|
273
292
|
'worklet';
|
|
274
293
|
|
|
294
|
+
const offsetTop = Math.max(0, (autoscrollThresholdOffset === null || autoscrollThresholdOffset === void 0 ? void 0 : autoscrollThresholdOffset.top) || 0);
|
|
295
|
+
const offsetBottom = Math.max(0, (autoscrollThresholdOffset === null || autoscrollThresholdOffset === void 0 ? void 0 : autoscrollThresholdOffset.bottom) || 0);
|
|
275
296
|
const threshold = Math.max(0, Math.min(autoscrollThreshold, 0.4));
|
|
276
|
-
const visibleHeight = flatListHeightY.value - (hiddenArea.top + hiddenArea.bottom);
|
|
277
|
-
const
|
|
278
|
-
const
|
|
297
|
+
const visibleHeight = flatListHeightY.value - (hiddenArea.top + hiddenArea.bottom) - (offsetTop + offsetBottom);
|
|
298
|
+
const area = visibleHeight * threshold;
|
|
299
|
+
const top = area + offsetTop;
|
|
300
|
+
const bottom = flatListHeightY.value - area - offsetBottom;
|
|
279
301
|
return {
|
|
280
302
|
top,
|
|
281
303
|
bottom
|
|
282
304
|
};
|
|
283
|
-
}, [autoscrollThreshold, flatListHeightY]);
|
|
305
|
+
}, [autoscrollThreshold, autoscrollThresholdOffset, flatListHeightY]);
|
|
284
306
|
const calculateThresholdAreaParent = (0, _react.useCallback)(hiddenArea => {
|
|
285
307
|
'worklet';
|
|
286
308
|
|
|
309
|
+
const offsetTop = Math.max(0, (autoscrollThresholdOffset === null || autoscrollThresholdOffset === void 0 ? void 0 : autoscrollThresholdOffset.top) || 0);
|
|
310
|
+
const offsetBottom = Math.max(0, (autoscrollThresholdOffset === null || autoscrollThresholdOffset === void 0 ? void 0 : autoscrollThresholdOffset.bottom) || 0);
|
|
287
311
|
const threshold = Math.max(0, Math.min(autoscrollThreshold, 0.4));
|
|
288
|
-
const
|
|
289
|
-
const
|
|
312
|
+
const area = flatListHeightY.value * threshold;
|
|
313
|
+
const top = area + offsetTop;
|
|
314
|
+
const bottom = flatListHeightY.value - area - offsetBottom;
|
|
290
315
|
|
|
291
316
|
// if the hidden area is 0 then we don't have a threshold area
|
|
292
317
|
// we might have floating errors like 0.0001 which we should ignore
|
|
@@ -294,7 +319,7 @@ const useReorderableListCore = ({
|
|
|
294
319
|
top: hiddenArea.top > 0.1 ? top + hiddenArea.top : 0,
|
|
295
320
|
bottom: hiddenArea.bottom > 0.1 ? bottom - hiddenArea.bottom : 0
|
|
296
321
|
};
|
|
297
|
-
}, [autoscrollThreshold, flatListHeightY]);
|
|
322
|
+
}, [autoscrollThreshold, autoscrollThresholdOffset, flatListHeightY]);
|
|
298
323
|
const shouldScrollParent = (0, _react.useCallback)(y => {
|
|
299
324
|
'worklet';
|
|
300
325
|
|
|
@@ -408,6 +433,9 @@ const useReorderableListCore = ({
|
|
|
408
433
|
// resetting shared values again fixes a flickeing bug in nested lists where
|
|
409
434
|
// after scrolling the parent list it would offset the new dragged item in another nested list
|
|
410
435
|
resetSharedValues();
|
|
436
|
+
if (shouldUpdateActiveItem) {
|
|
437
|
+
(0, _reactNativeReanimated.runOnJS)(setActiveIndex)(index);
|
|
438
|
+
}
|
|
411
439
|
dragInitialScrollOffsetY.value = flatListScrollOffsetY.value;
|
|
412
440
|
scrollViewDragInitialScrollOffsetY.value = scrollViewScrollOffsetY ? scrollViewScrollOffsetY.value : 0;
|
|
413
441
|
draggedHeight.value = itemHeight.value[index];
|
|
@@ -423,7 +451,7 @@ const useReorderableListCore = ({
|
|
|
423
451
|
index
|
|
424
452
|
});
|
|
425
453
|
}
|
|
426
|
-
}, [resetSharedValues, dragInitialScrollOffsetY, scrollViewScrollOffsetY, scrollViewDragInitialScrollOffsetY, setScrollEnabled, currentIndex, previousIndex, draggedHeight, draggedIndex, state, flatListScrollOffsetY, itemHeight, onDragStart, runDefaultDragAnimations]);
|
|
454
|
+
}, [resetSharedValues, shouldUpdateActiveItem, dragInitialScrollOffsetY, scrollViewScrollOffsetY, scrollViewDragInitialScrollOffsetY, setScrollEnabled, currentIndex, previousIndex, draggedHeight, draggedIndex, state, flatListScrollOffsetY, itemHeight, onDragStart, runDefaultDragAnimations]);
|
|
427
455
|
const handleFlatListLayout = (0, _react.useCallback)(e => {
|
|
428
456
|
nestedFlatListPositionY.value = e.nativeEvent.layout.y;
|
|
429
457
|
flatListHeightY.value = e.nativeEvent.layout.height;
|