react-native-reorderable-list 0.14.1 → 0.16.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 +4 -2
- package/lib/commonjs/components/NestedReorderableList.js +5 -7
- package/lib/commonjs/components/NestedReorderableList.js.map +1 -1
- package/lib/commonjs/components/ReorderableList.js +3 -7
- package/lib/commonjs/components/ReorderableList.js.map +1 -1
- package/lib/commonjs/components/ReorderableListCell.js +4 -2
- package/lib/commonjs/components/ReorderableListCell.js.map +1 -1
- package/lib/commonjs/components/ReorderableListCore.js +94 -33
- package/lib/commonjs/components/ReorderableListCore.js.map +1 -1
- package/lib/commonjs/components/ScrollViewContainer.js +11 -10
- package/lib/commonjs/components/ScrollViewContainer.js.map +1 -1
- package/lib/commonjs/contexts/ReorderableListContext.js.map +1 -1
- package/lib/commonjs/hooks/index.js +34 -12
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/usePropAsSharedValue.js +17 -0
- package/lib/commonjs/hooks/usePropAsSharedValue.js.map +1 -0
- package/lib/commonjs/hooks/useStableCallback.js +21 -0
- package/lib/commonjs/hooks/useStableCallback.js.map +1 -0
- package/lib/commonjs/types/misc.js.map +1 -1
- package/lib/module/components/NestedReorderableList.js +5 -7
- package/lib/module/components/NestedReorderableList.js.map +1 -1
- package/lib/module/components/ReorderableList.js +3 -7
- package/lib/module/components/ReorderableList.js.map +1 -1
- package/lib/module/components/ReorderableListCell.js +4 -2
- package/lib/module/components/ReorderableListCell.js.map +1 -1
- package/lib/module/components/ReorderableListCore.js +95 -34
- package/lib/module/components/ReorderableListCore.js.map +1 -1
- package/lib/module/components/ScrollViewContainer.js +10 -9
- package/lib/module/components/ScrollViewContainer.js.map +1 -1
- package/lib/module/contexts/ReorderableListContext.js.map +1 -1
- package/lib/module/hooks/index.js +4 -2
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/usePropAsSharedValue.js +10 -0
- package/lib/module/hooks/usePropAsSharedValue.js.map +1 -0
- package/lib/module/hooks/useStableCallback.js +15 -0
- package/lib/module/hooks/useStableCallback.js.map +1 -0
- package/lib/module/types/misc.js.map +1 -1
- package/lib/typescript/components/NestedReorderableList.d.ts.map +1 -1
- package/lib/typescript/components/ReorderableList.d.ts.map +1 -1
- package/lib/typescript/components/ReorderableListCell.d.ts.map +1 -1
- package/lib/typescript/components/ReorderableListCore.d.ts +2 -3
- package/lib/typescript/components/ReorderableListCore.d.ts.map +1 -1
- package/lib/typescript/components/ScrollViewContainer.d.ts.map +1 -1
- package/lib/typescript/contexts/ReorderableListContext.d.ts +2 -1
- package/lib/typescript/contexts/ReorderableListContext.d.ts.map +1 -1
- package/lib/typescript/contexts/ScrollViewContainerContext.d.ts +2 -2
- package/lib/typescript/contexts/ScrollViewContainerContext.d.ts.map +1 -1
- package/lib/typescript/hooks/index.d.ts +4 -2
- package/lib/typescript/hooks/index.d.ts.map +1 -1
- package/lib/typescript/hooks/usePropAsSharedValue.d.ts +3 -0
- package/lib/typescript/hooks/usePropAsSharedValue.d.ts.map +1 -0
- package/lib/typescript/hooks/useStableCallback.d.ts +4 -0
- package/lib/typescript/hooks/useStableCallback.d.ts.map +1 -0
- package/lib/typescript/types/misc.d.ts +3 -1
- package/lib/typescript/types/misc.d.ts.map +1 -1
- package/lib/typescript/types/props.d.ts +10 -2
- package/lib/typescript/types/props.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/NestedReorderableList.tsx +5 -6
- package/src/components/ReorderableList.tsx +4 -5
- package/src/components/ReorderableListCell.tsx +12 -3
- package/src/components/ReorderableListCore.tsx +113 -49
- package/src/components/ScrollViewContainer.tsx +11 -8
- package/src/contexts/ReorderableListContext.ts +2 -1
- package/src/contexts/ScrollViewContainerContext.ts +2 -2
- package/src/hooks/index.ts +4 -2
- package/src/hooks/usePropAsSharedValue.ts +13 -0
- package/src/hooks/useStableCallback.ts +16 -0
- package/src/types/misc.ts +8 -1
- package/src/types/props.ts +10 -2
package/README.md
CHANGED
|
@@ -66,6 +66,8 @@ This component uses a [FlatList](https://reactnative.dev/docs/flatlist) and it e
|
|
|
66
66
|
| autoscrollActivationDelta | `number` | No | `5` | Allows configuring the delta for autoscroll activation when dragging an item in the same direction as the autoscroll. This is particularly useful when an item is dragged within the autoscroll area to account for minor unintentional movements. |
|
|
67
67
|
| 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. |
|
|
68
68
|
| 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. |
|
|
69
|
+
| itemLayoutAnimation | `ComponentProps<typeof Animated.View>['layout']>` | No | N/A | Layout animation when the item is added to and/or removed from the view hierarchy. To skip entering or exiting animations use the LayoutAnimationConfig component from [Reanimated](https://docs.swmansion.com/react-native-reanimated). |
|
|
70
|
+
| dragEnabled | `boolean` | No | `true` | Whether dragging items is enabled. |
|
|
69
71
|
| shouldUpdateActiveItem | boolean | No | `false` | Whether the active item should be updated. Enables usage of `useIsActive` hook. |
|
|
70
72
|
| panGesture | `PanGesture` | No | N/A | Custom instance of pan gesture. See [GestureHandler docs](https://docs.swmansion.com/react-native-gesture-handler) for further info. |
|
|
71
73
|
| onReorder | `(event: { from: number, to: number }) => void` | Yes | N/A | Event fired after an item is released and the list is reordered. |
|
|
@@ -96,7 +98,7 @@ This component allows nesting a reorderable list within a [ScrollViewContainer](
|
|
|
96
98
|
|
|
97
99
|
| Props | Type | Required | Default | Description |
|
|
98
100
|
| ---------- | --------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
99
|
-
| scrollable | `boolean` | No | false | Whether the nested list is scrollable or not. If the nested list has a fixed height and it's scrollable it should be set to `true`, otherwise `false`. |
|
|
101
|
+
| scrollable | `boolean` | No | `false` | Whether the nested list is scrollable or not. If the nested list has a fixed height and it's scrollable it should be set to `true`, otherwise `false`. |
|
|
100
102
|
|
|
101
103
|
## Hooks
|
|
102
104
|
|
|
@@ -189,7 +191,7 @@ import {Gesture} from 'react-native-gesture-handler';
|
|
|
189
191
|
|
|
190
192
|
// If it doesn't work try with bigger values.
|
|
191
193
|
const panGesture = useMemo(
|
|
192
|
-
() => Gesture.Pan().activeOffsetX([-20, 20]).activeOffsetY(0),
|
|
194
|
+
() => Gesture.Pan().activeOffsetX([-20, 20]).activeOffsetY([0, 0]),
|
|
193
195
|
[],
|
|
194
196
|
);
|
|
195
197
|
|
|
@@ -13,7 +13,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
13
13
|
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); }
|
|
14
14
|
const NestedReorderableListWithRef = ({
|
|
15
15
|
scrollable,
|
|
16
|
-
scrollEnabled = true,
|
|
17
16
|
...rest
|
|
18
17
|
}, ref) => {
|
|
19
18
|
const {
|
|
@@ -21,9 +20,9 @@ const NestedReorderableListWithRef = ({
|
|
|
21
20
|
scrollViewScrollOffsetY,
|
|
22
21
|
scrollViewPageY,
|
|
23
22
|
scrollViewHeightY,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
scrollViewScrollEnabledProp,
|
|
24
|
+
scrollViewCurrentScrollEnabled,
|
|
25
|
+
outerScrollGesture
|
|
27
26
|
} = (0, _hooks.useContext)(_contexts.ScrollViewContainerContext);
|
|
28
27
|
return /*#__PURE__*/_react.default.createElement(_ReorderableListCore.ReorderableListCore, _extends({}, rest, {
|
|
29
28
|
ref: ref,
|
|
@@ -32,10 +31,9 @@ const NestedReorderableListWithRef = ({
|
|
|
32
31
|
scrollViewPageY: scrollViewPageY,
|
|
33
32
|
scrollViewHeightY: scrollViewHeightY,
|
|
34
33
|
outerScrollGesture: outerScrollGesture,
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
scrollViewScrollEnabledProp: scrollViewScrollEnabledProp,
|
|
35
|
+
scrollViewCurrentScrollEnabled: scrollViewCurrentScrollEnabled,
|
|
37
36
|
scrollable: scrollable,
|
|
38
|
-
scrollEnabled: scrollEnabled,
|
|
39
37
|
nestedScrollEnabled: true
|
|
40
38
|
}));
|
|
41
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_ReorderableListCore","_contexts","_hooks","_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","NestedReorderableListWithRef","scrollable","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_ReorderableListCore","_contexts","_hooks","_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","NestedReorderableListWithRef","scrollable","rest","ref","scrollViewContainerRef","scrollViewScrollOffsetY","scrollViewPageY","scrollViewHeightY","scrollViewScrollEnabledProp","scrollViewCurrentScrollEnabled","outerScrollGesture","useContext","ScrollViewContainerContext","createElement","ReorderableListCore","nestedScrollEnabled","NestedReorderableList","exports","forwardRef"],"sourceRoot":"../../../src","sources":["components/NestedReorderableList.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAoC,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,I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,CAAA,IAAAC,CAAA,OAAAY,cAAA,CAAAC,IAAA,CAAAb,CAAA,EAAAD,CAAA,MAAAM,CAAA,CAAAN,CAAA,IAAAC,CAAA,CAAAD,CAAA,aAAAM,CAAA,KAAAW,QAAA,CAAAK,KAAA,OAAAF,SAAA;AAGpC,MAAMG,4BAA4B,GAAGA,CACnC;EAACC,UAAU;EAAE,GAAGC;AAAmC,CAAC,EACpDC,GAAqC,KAClC;EACH,MAAM;IACJC,sBAAsB;IACtBC,uBAAuB;IACvBC,eAAe;IACfC,iBAAiB;IACjBC,2BAA2B;IAC3BC,8BAA8B;IAC9BC;EACF,CAAC,GAAG,IAAAC,iBAAU,EAACC,oCAA0B,CAAC;EAE1C,oBACE5C,MAAA,CAAAY,OAAA,CAAAiC,aAAA,CAAC1C,oBAAA,CAAA2C,mBAAmB,EAAApB,QAAA,KACdQ,IAAI;IACRC,GAAG,EAAEA,GAAI;IACTC,sBAAsB,EAAEA,sBAAuB;IAC/CC,uBAAuB,EAAEA,uBAAwB;IACjDC,eAAe,EAAEA,eAAgB;IACjCC,iBAAiB,EAAEA,iBAAkB;IACrCG,kBAAkB,EAAEA,kBAAmB;IACvCF,2BAA2B,EAAEA,2BAA4B;IACzDC,8BAA8B,EAAEA,8BAA+B;IAC/DR,UAAU,EAAEA,UAAW;IACvBc,mBAAmB;EAAA,EACpB,CAAC;AAEN,CAAC;AAEM,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,gBAAG,IAAAE,iBAAU,EAC7ClB,4BACF,CAEgB","ignoreList":[]}
|
|
@@ -9,19 +9,15 @@ var _ReorderableListCore = require("./ReorderableListCore");
|
|
|
9
9
|
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); }
|
|
10
10
|
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; }
|
|
11
11
|
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); }
|
|
12
|
-
const ReorderableListWithRef = ({
|
|
13
|
-
scrollEnabled = true,
|
|
14
|
-
...rest
|
|
15
|
-
}, ref) => /*#__PURE__*/_react.default.createElement(_ReorderableListCore.ReorderableListCore, _extends({}, rest, {
|
|
12
|
+
const ReorderableListWithRef = (props, ref) => /*#__PURE__*/_react.default.createElement(_ReorderableListCore.ReorderableListCore, _extends({}, props, {
|
|
16
13
|
ref: ref,
|
|
17
|
-
scrollEnabled: scrollEnabled,
|
|
18
14
|
scrollViewContainerRef: undefined,
|
|
19
15
|
scrollViewScrollOffsetY: undefined,
|
|
20
16
|
scrollViewPageY: undefined,
|
|
21
17
|
scrollViewHeightY: undefined,
|
|
22
18
|
outerScrollGesture: undefined,
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
scrollViewScrollEnabledProp: undefined,
|
|
20
|
+
scrollViewCurrentScrollEnabled: undefined,
|
|
25
21
|
scrollable: true
|
|
26
22
|
}));
|
|
27
23
|
const ReorderableList = exports.ReorderableList = /*#__PURE__*/(0, _react.forwardRef)(ReorderableListWithRef);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_ReorderableListCore","_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","ReorderableListWithRef","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_ReorderableListCore","_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","ReorderableListWithRef","props","ref","createElement","ReorderableListCore","scrollViewContainerRef","undefined","scrollViewScrollOffsetY","scrollViewPageY","scrollViewHeightY","outerScrollGesture","scrollViewScrollEnabledProp","scrollViewCurrentScrollEnabled","scrollable","ReorderableList","exports","forwardRef"],"sourceRoot":"../../../src","sources":["components/ReorderableList.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,oBAAA,GAAAD,OAAA;AAA0D,SAAAE,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,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CA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D,eAAA,gBAAG,IAAAE,iBAAU,EAAChB,sBAAsB,CAEhD","ignoreList":[]}
|
|
@@ -26,7 +26,8 @@ const ReorderableListCell = exports.ReorderableListCell = /*#__PURE__*/(0, _reac
|
|
|
26
26
|
currentIndex,
|
|
27
27
|
draggedHeight,
|
|
28
28
|
activeIndex,
|
|
29
|
-
cellAnimations
|
|
29
|
+
cellAnimations,
|
|
30
|
+
itemLayoutAnimation
|
|
30
31
|
} = (0, _hooks.useContext)(_contexts.ReorderableListContext);
|
|
31
32
|
const dragHandler = (0, _react.useCallback)(() => (0, _reactNativeReanimated.runOnUI)(startDrag)(index), [startDrag, index]);
|
|
32
33
|
const isActive = activeIndex === index;
|
|
@@ -98,7 +99,8 @@ const ReorderableListCell = exports.ReorderableListCell = /*#__PURE__*/(0, _reac
|
|
|
98
99
|
value: contextValue
|
|
99
100
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
100
101
|
style: animatedStyle,
|
|
101
|
-
onLayout: handleLayout
|
|
102
|
+
onLayout: handleLayout,
|
|
103
|
+
layout: itemLayoutAnimation.current
|
|
102
104
|
}, children));
|
|
103
105
|
});
|
|
104
106
|
//# sourceMappingURL=ReorderableListCell.js.map
|
|
@@ -1 +1 @@
|
|
|
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","moveUp","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,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAYvC,MAAMW,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,gBAAG,IAAAE,WAAI,EACrC,CAAK;EACHC,KAAK;EACLC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRC,UAAU;EACVC,UAAU;EACVC,KAAK;EACLC,YAAY;EACZC;AAC2B,CAAC,KAAK;EACjC,MAAM;
|
|
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","itemLayoutAnimation","useContext","ReorderableListContext","dragHandler","useCallback","runOnUI","isActive","contextValue","useMemo","itemTranslateY","useSharedValue","isActiveCell","useDerivedValue","value","useAnimatedReaction","moveUp","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","current"],"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;A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EACDxC,cAAc,EACd,CAAC,WAAW,CACd,CAAC;IACH;IAEA,OAAO;MACL+B,SAAS,EAAE,CAAC;QAACC,UAAU,EAAEtB,cAAc,CAACI;MAAK,CAAC,CAAC;MAC/C;MACA;MACA0B,MAAM,EAAE;IACV,CAAC;EACH,CAAC,CAAC;EAEF,MAAMC,YAAY,GAAI3E,CAAoB,IAAK;IAC7C,IAAAwC,8BAAO,EAAC,CAACoC,CAAS,EAAEC,MAAc,KAAK;MACrCnD,UAAU,CAACsB,KAAK,CAAC1B,KAAK,CAAC,GAAGsD,CAAC;MAC3BjD,UAAU,CAACqB,KAAK,CAAC1B,KAAK,CAAC,GAAGuD,MAAM;IAClC,CAAC,CAAC,CAAC7E,CAAC,CAAC8E,WAAW,CAACC,MAAM,CAACH,CAAC,EAAE5E,CAAC,CAAC8E,WAAW,CAACC,MAAM,CAACF,MAAM,CAAC;IAEvDpD,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAGzB,CAAC,CAAC;EACf,CAAC;EAED,oBACER,MAAA,CAAAa,OAAA,CAAA2E,aAAA,CAACpF,SAAA,CAAAqF,sBAAsB,CAACC,QAAQ;IAAClC,KAAK,EAAEN;EAAa,gBACnDlD,MAAA,CAAAa,OAAA,CAAA2E,aAAA,CAACrF,sBAAA,CAAAU,OAAQ,CAAC8E,IAAI;IACZC,KAAK,EAAErB,aAAc;IACrBtC,QAAQ,EAAEkD,YAAa;IACvBI,MAAM,EAAE5C,mBAAmB,CAACkD;EAAQ,GACnC7D,QACY,CACgB,CAAC;AAEtC,CACF,CAAC","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ var _contexts = require("../contexts");
|
|
|
12
12
|
var _types = require("../types");
|
|
13
13
|
var _constants = require("./constants");
|
|
14
14
|
var _ReorderableListCell = require("./ReorderableListCell");
|
|
15
|
+
var _hooks = require("../hooks");
|
|
15
16
|
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); }
|
|
16
17
|
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; }
|
|
17
18
|
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); }
|
|
@@ -33,24 +34,27 @@ const ReorderableListCore = ({
|
|
|
33
34
|
scrollViewPageY,
|
|
34
35
|
scrollViewHeightY,
|
|
35
36
|
scrollViewScrollOffsetY,
|
|
36
|
-
|
|
37
|
+
scrollViewScrollEnabledProp,
|
|
38
|
+
scrollViewCurrentScrollEnabled,
|
|
37
39
|
scrollable,
|
|
38
40
|
outerScrollGesture,
|
|
39
41
|
cellAnimations,
|
|
42
|
+
dragEnabled = true,
|
|
40
43
|
shouldUpdateActiveItem,
|
|
44
|
+
itemLayoutAnimation,
|
|
41
45
|
panGesture,
|
|
42
46
|
panEnabled = true,
|
|
43
47
|
panActivateAfterLongPress,
|
|
44
48
|
data,
|
|
49
|
+
keyExtractor,
|
|
45
50
|
...rest
|
|
46
51
|
}, ref) => {
|
|
47
|
-
|
|
48
|
-
// but internally we would treat it as false, so we force true.
|
|
49
|
-
const initialScrollEnabled = typeof rest.scrollEnabled === 'undefined' ? true : rest.scrollEnabled;
|
|
50
|
-
const initialScrollViewScrollEnabled = typeof rest.initialScrollViewScrollEnabled === 'undefined' ? true : rest.initialScrollViewScrollEnabled;
|
|
52
|
+
const scrollEnabled = rest.scrollEnabled ?? true;
|
|
51
53
|
const flatListRef = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
54
|
+
const markedCellsRef = (0, _react.useRef)();
|
|
52
55
|
const [activeIndex, setActiveIndex] = (0, _react.useState)(-1);
|
|
53
|
-
const
|
|
56
|
+
const prevItemCount = (0, _react.useRef)(data.length);
|
|
57
|
+
const currentScrollEnabled = (0, _reactNativeReanimated.useSharedValue)(scrollEnabled);
|
|
54
58
|
const gestureState = (0, _reactNativeReanimated.useSharedValue)(_reactNativeGestureHandler.State.UNDETERMINED);
|
|
55
59
|
const currentY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
56
60
|
const currentTranslationY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
@@ -81,20 +85,21 @@ const ReorderableListCore = ({
|
|
|
81
85
|
const state = (0, _reactNativeReanimated.useSharedValue)(_types.ReorderableListState.IDLE);
|
|
82
86
|
const dragEndHandlers = (0, _reactNativeReanimated.useSharedValue)([]);
|
|
83
87
|
const startY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
84
|
-
const duration = (0, _reactNativeReanimated.useSharedValue)(animationDuration);
|
|
85
88
|
const scaleDefault = (0, _reactNativeReanimated.useSharedValue)(1);
|
|
86
89
|
const opacityDefault = (0, _reactNativeReanimated.useSharedValue)(1);
|
|
87
90
|
const dragDirection = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
88
91
|
const lastDragDirectionPivot = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
89
|
-
const
|
|
90
|
-
|
|
92
|
+
const itemLayoutAnimationPropRef = (0, _react.useRef)(itemLayoutAnimation);
|
|
93
|
+
itemLayoutAnimationPropRef.current = itemLayoutAnimation;
|
|
94
|
+
const keyExtractorPropRef = (0, _react.useRef)(keyExtractor);
|
|
95
|
+
keyExtractorPropRef.current = keyExtractor;
|
|
96
|
+
const scrollEnabledProp = (0, _hooks.usePropAsSharedValue)(scrollEnabled);
|
|
97
|
+
const animationDurationProp = (0, _hooks.usePropAsSharedValue)(animationDuration);
|
|
98
|
+
const autoscrollActivationDeltaProp = (0, _hooks.usePropAsSharedValue)(autoscrollActivationDelta);
|
|
99
|
+
const dragEnabledProp = (0, _hooks.usePropAsSharedValue)(dragEnabled ?? true);
|
|
91
100
|
|
|
92
101
|
// Position of the list relative to the scroll container
|
|
93
102
|
const nestedFlatListPositionY = (0, _reactNativeReanimated.useDerivedValue)(() => flatListPageY.value - ((scrollViewPageY === null || scrollViewPageY === void 0 ? void 0 : scrollViewPageY.value) || 0));
|
|
94
|
-
(0, _react.useEffect)(() => {
|
|
95
|
-
duration.value = animationDuration;
|
|
96
|
-
autoscrollDelta.value = autoscrollActivationDelta;
|
|
97
|
-
}, [duration, animationDuration, autoscrollDelta, autoscrollActivationDelta, itemCount]);
|
|
98
103
|
(0, _react.useEffect)(() => {
|
|
99
104
|
itemCount.value = data.length;
|
|
100
105
|
|
|
@@ -111,12 +116,44 @@ const ReorderableListCore = ({
|
|
|
111
116
|
}
|
|
112
117
|
prevItemCount.current = data.length;
|
|
113
118
|
}, [data.length, itemHeight, itemOffset, itemCount]);
|
|
119
|
+
(0, _react.useEffect)(() => {
|
|
120
|
+
if (!markedCellsRef.current ||
|
|
121
|
+
// Clean keys once they surpass by 10% the size of the list itself.
|
|
122
|
+
markedCellsRef.current.size <= data.length + Math.ceil(data.length * 0.1)) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Can be heavy to loop through all items, defer the task to run after interactions.
|
|
127
|
+
const task = _reactNative.InteractionManager.runAfterInteractions(() => {
|
|
128
|
+
if (!markedCellsRef.current) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const map = new Map();
|
|
132
|
+
for (let i = 0; i < data.length; i++) {
|
|
133
|
+
var _keyExtractorPropRef$;
|
|
134
|
+
const key = ((_keyExtractorPropRef$ = keyExtractorPropRef.current) === null || _keyExtractorPropRef$ === void 0 ? void 0 : _keyExtractorPropRef$.call(keyExtractorPropRef, data[i], i)) || i.toString();
|
|
135
|
+
if (markedCellsRef.current.has(key)) {
|
|
136
|
+
map.set(key, markedCellsRef.current.get(key));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
markedCellsRef.current = map;
|
|
140
|
+
});
|
|
141
|
+
return () => {
|
|
142
|
+
task.cancel();
|
|
143
|
+
};
|
|
144
|
+
}, [data]);
|
|
145
|
+
const createCellKey = (0, _react.useCallback)(cellKey => {
|
|
146
|
+
var _markedCellsRef$curre;
|
|
147
|
+
const mark = ((_markedCellsRef$curre = markedCellsRef.current) === null || _markedCellsRef$curre === void 0 ? void 0 : _markedCellsRef$curre.get(cellKey)) || 0;
|
|
148
|
+
return `${cellKey}#${mark}`;
|
|
149
|
+
}, []);
|
|
114
150
|
const listContextValue = (0, _react.useMemo)(() => ({
|
|
115
151
|
draggedHeight,
|
|
116
152
|
currentIndex,
|
|
117
153
|
draggedIndex,
|
|
118
154
|
dragEndHandlers,
|
|
119
155
|
activeIndex,
|
|
156
|
+
itemLayoutAnimation: itemLayoutAnimationPropRef,
|
|
120
157
|
cellAnimations: {
|
|
121
158
|
...cellAnimations,
|
|
122
159
|
transform: cellAnimations && 'transform' in cellAnimations ? cellAnimations.transform : [{
|
|
@@ -124,7 +161,7 @@ const ReorderableListCore = ({
|
|
|
124
161
|
}],
|
|
125
162
|
opacity: cellAnimations && 'opacity' in cellAnimations ? cellAnimations.opacity : opacityDefault
|
|
126
163
|
}
|
|
127
|
-
}), [draggedHeight, currentIndex, draggedIndex, dragEndHandlers, activeIndex, cellAnimations, scaleDefault, opacityDefault]);
|
|
164
|
+
}), [draggedHeight, currentIndex, draggedIndex, dragEndHandlers, activeIndex, cellAnimations, itemLayoutAnimationPropRef, scaleDefault, opacityDefault]);
|
|
128
165
|
|
|
129
166
|
/**
|
|
130
167
|
* Decides the intended drag direction of the user.
|
|
@@ -140,12 +177,12 @@ const ReorderableListCore = ({
|
|
|
140
177
|
if (direction !== dragDirection.value) {
|
|
141
178
|
if (lastDragDirectionPivot.value === null) {
|
|
142
179
|
lastDragDirectionPivot.value = e.absoluteY;
|
|
143
|
-
} else if (Math.abs(e.absoluteY - lastDragDirectionPivot.value) >=
|
|
180
|
+
} else if (Math.abs(e.absoluteY - lastDragDirectionPivot.value) >= autoscrollActivationDeltaProp.value) {
|
|
144
181
|
dragDirection.value = direction;
|
|
145
182
|
lastDragDirectionPivot.value = e.absoluteY;
|
|
146
183
|
}
|
|
147
184
|
}
|
|
148
|
-
}, [dragDirection, lastDragDirectionPivot,
|
|
185
|
+
}, [dragDirection, lastDragDirectionPivot, autoscrollActivationDeltaProp]);
|
|
149
186
|
const setCurrentItemDragCenterY = (0, _react.useCallback)(e => {
|
|
150
187
|
'worklet';
|
|
151
188
|
|
|
@@ -206,22 +243,24 @@ const ReorderableListCore = ({
|
|
|
206
243
|
}, [panActivateAfterLongPress, panEnabled, panGestureHandler]);
|
|
207
244
|
const gestureHandler = (0, _react.useMemo)(() => _reactNativeGestureHandler.Gesture.Simultaneous(_reactNativeGestureHandler.Gesture.Native(), panGestureHandlerWithPropOptions), [panGestureHandlerWithPropOptions]);
|
|
208
245
|
const setScrollEnabled = (0, _react.useCallback)(enabled => {
|
|
209
|
-
//
|
|
210
|
-
if (
|
|
246
|
+
// When re-enabling the scroll of the flatlist we check whether its prop is set to true.
|
|
247
|
+
if (enabled && scrollEnabledProp.value || !enabled) {
|
|
211
248
|
var _flatListRef$current;
|
|
212
|
-
|
|
249
|
+
currentScrollEnabled.value = enabled;
|
|
213
250
|
(_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 || _flatListRef$current.setNativeProps({
|
|
214
251
|
scrollEnabled: enabled
|
|
215
252
|
});
|
|
216
253
|
}
|
|
217
|
-
if (scrollViewContainerRef &&
|
|
254
|
+
if (scrollViewContainerRef && scrollViewScrollEnabledProp && scrollViewCurrentScrollEnabled && (
|
|
255
|
+
// When re-enabling the scroll of the container we check whether its prop is set to true.
|
|
256
|
+
enabled && scrollViewScrollEnabledProp !== null && scrollViewScrollEnabledProp !== void 0 && scrollViewScrollEnabledProp.value || !enabled)) {
|
|
218
257
|
var _scrollViewContainerR;
|
|
219
|
-
|
|
258
|
+
scrollViewCurrentScrollEnabled.value = enabled;
|
|
220
259
|
(_scrollViewContainerR = scrollViewContainerRef.current) === null || _scrollViewContainerR === void 0 || _scrollViewContainerR.setNativeProps({
|
|
221
260
|
scrollEnabled: enabled
|
|
222
261
|
});
|
|
223
262
|
}
|
|
224
|
-
}, [
|
|
263
|
+
}, [flatListRef, scrollEnabledProp, currentScrollEnabled, scrollViewScrollEnabledProp, scrollViewCurrentScrollEnabled, scrollViewContainerRef]);
|
|
225
264
|
const resetSharedValues = (0, _react.useCallback)(() => {
|
|
226
265
|
'worklet';
|
|
227
266
|
|
|
@@ -235,10 +274,27 @@ const ReorderableListCore = ({
|
|
|
235
274
|
currentItemDragCenterY.value = null;
|
|
236
275
|
}, [state, draggedIndex, dragY, dragScrollTranslationY, scrollViewDragScrollTranslationY, dragDirection, lastDragDirectionPivot, currentItemDragCenterY]);
|
|
237
276
|
const resetSharedValuesAfterAnimations = (0, _react.useCallback)(() => {
|
|
238
|
-
setTimeout((0, _reactNativeReanimated.runOnUI)(resetSharedValues),
|
|
239
|
-
}, [resetSharedValues,
|
|
277
|
+
setTimeout((0, _reactNativeReanimated.runOnUI)(resetSharedValues), animationDurationProp.value);
|
|
278
|
+
}, [resetSharedValues, animationDurationProp]);
|
|
279
|
+
const markCells = (fromIndex, toIndex) => {
|
|
280
|
+
if (!markedCellsRef.current) {
|
|
281
|
+
markedCellsRef.current = new Map();
|
|
282
|
+
}
|
|
283
|
+
const start = Math.min(fromIndex, toIndex);
|
|
284
|
+
const end = Math.max(fromIndex, toIndex);
|
|
285
|
+
for (let i = start; i <= end; i++) {
|
|
286
|
+
var _keyExtractorPropRef$2;
|
|
287
|
+
const cellKey = ((_keyExtractorPropRef$2 = keyExtractorPropRef.current) === null || _keyExtractorPropRef$2 === void 0 ? void 0 : _keyExtractorPropRef$2.call(keyExtractorPropRef, data[i], i)) || i.toString();
|
|
288
|
+
if (!markedCellsRef.current.has(cellKey)) {
|
|
289
|
+
markedCellsRef.current.set(cellKey, 1);
|
|
290
|
+
} else {
|
|
291
|
+
markedCellsRef.current.delete(cellKey);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
};
|
|
240
295
|
const reorder = (fromIndex, toIndex) => {
|
|
241
296
|
(0, _reactNativeReanimated.runOnUI)(resetSharedValues)();
|
|
297
|
+
markCells(fromIndex, toIndex);
|
|
242
298
|
if (fromIndex !== toIndex) {
|
|
243
299
|
onReorder({
|
|
244
300
|
from: fromIndex,
|
|
@@ -353,7 +409,7 @@ const ReorderableListCore = ({
|
|
|
353
409
|
if (dragY.value !== newTopPosition) {
|
|
354
410
|
// animate dragged item to its new position on release
|
|
355
411
|
dragY.value = (0, _reactNativeReanimated.withTiming)(newTopPosition, {
|
|
356
|
-
duration:
|
|
412
|
+
duration: animationDurationProp.value,
|
|
357
413
|
easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.ease)
|
|
358
414
|
}, () => {
|
|
359
415
|
(0, _reactNativeReanimated.runOnJS)(reorder)(draggedIndex.value, currentIndex.value);
|
|
@@ -515,7 +571,7 @@ const ReorderableListCore = ({
|
|
|
515
571
|
// checking if the list is not scrollable instead of the scrolling state
|
|
516
572
|
// fixes a bug on iOS where the item is shifted after autoscrolling and then
|
|
517
573
|
// moving away from autoscroll area
|
|
518
|
-
if (!
|
|
574
|
+
if (!currentScrollEnabled.value) {
|
|
519
575
|
dragScrollTranslationY.value = flatListScrollOffsetY.value - dragInitialScrollOffsetY.value;
|
|
520
576
|
}
|
|
521
577
|
if (state.value === _types.ReorderableListState.AUTOSCROLL) {
|
|
@@ -529,10 +585,10 @@ const ReorderableListCore = ({
|
|
|
529
585
|
|
|
530
586
|
// container scroll handler
|
|
531
587
|
(0, _reactNativeReanimated.useAnimatedReaction)(() => scrollViewScrollOffsetY === null || scrollViewScrollOffsetY === void 0 ? void 0 : scrollViewScrollOffsetY.value, value => {
|
|
532
|
-
if (value &&
|
|
588
|
+
if (value && scrollViewCurrentScrollEnabled) {
|
|
533
589
|
// checking if the list is not scrollable instead of the scrolling state
|
|
534
590
|
// fixes a bug on iOS where the item is shifted after autoscrolling and moving away from the area
|
|
535
|
-
if (!
|
|
591
|
+
if (!scrollViewCurrentScrollEnabled.value) {
|
|
536
592
|
scrollViewDragScrollTranslationY.value = value - scrollViewDragInitialScrollOffsetY.value;
|
|
537
593
|
}
|
|
538
594
|
if (state.value === _types.ReorderableListState.AUTOSCROLL) {
|
|
@@ -547,6 +603,10 @@ const ReorderableListCore = ({
|
|
|
547
603
|
const startDrag = (0, _react.useCallback)(index => {
|
|
548
604
|
'worklet';
|
|
549
605
|
|
|
606
|
+
if (!dragEnabledProp.value) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
|
|
550
610
|
// allow new drag when item is completely released
|
|
551
611
|
if (state.value === _types.ReorderableListState.IDLE) {
|
|
552
612
|
// resetting shared values again fixes a flickeing bug in nested lists where
|
|
@@ -569,7 +629,7 @@ const ReorderableListCore = ({
|
|
|
569
629
|
index
|
|
570
630
|
});
|
|
571
631
|
}
|
|
572
|
-
}, [resetSharedValues, shouldUpdateActiveItem, dragInitialScrollOffsetY, scrollViewScrollOffsetY, scrollViewDragInitialScrollOffsetY, setScrollEnabled, currentIndex, draggedHeight, draggedIndex, state, flatListScrollOffsetY, itemHeight, onDragStart, runDefaultDragAnimations]);
|
|
632
|
+
}, [dragEnabledProp, resetSharedValues, shouldUpdateActiveItem, dragInitialScrollOffsetY, scrollViewScrollOffsetY, scrollViewDragInitialScrollOffsetY, setScrollEnabled, currentIndex, draggedHeight, draggedIndex, state, flatListScrollOffsetY, itemHeight, onDragStart, runDefaultDragAnimations]);
|
|
573
633
|
const handleFlatListLayout = (0, _react.useCallback)(e => {
|
|
574
634
|
flatListHeightY.value = e.nativeEvent.layout.height;
|
|
575
635
|
|
|
@@ -608,19 +668,19 @@ const ReorderableListCore = ({
|
|
|
608
668
|
return gestureHandler;
|
|
609
669
|
}, [scrollable, outerScrollGesture, gestureHandler]);
|
|
610
670
|
const composedScrollHandler = (0, _reactNativeReanimated.useComposedEventHandler)([handleScroll, onScroll || null]);
|
|
611
|
-
const renderAnimatedCell = (0,
|
|
671
|
+
const renderAnimatedCell = (0, _hooks.useStableCallback)(({
|
|
612
672
|
cellKey,
|
|
613
673
|
...props
|
|
614
674
|
}) => /*#__PURE__*/_react.default.createElement(_ReorderableListCell.ReorderableListCell, _extends({}, props, {
|
|
615
675
|
// forces remount with key change on reorder
|
|
616
|
-
key:
|
|
676
|
+
key: createCellKey(cellKey),
|
|
617
677
|
itemOffset: itemOffset,
|
|
618
678
|
itemHeight: itemHeight,
|
|
619
679
|
dragY: dragY,
|
|
620
680
|
draggedIndex: draggedIndex,
|
|
621
|
-
animationDuration:
|
|
681
|
+
animationDuration: animationDurationProp,
|
|
622
682
|
startDrag: startDrag
|
|
623
|
-
}))
|
|
683
|
+
})));
|
|
624
684
|
return /*#__PURE__*/_react.default.createElement(_contexts.ReorderableListContext.Provider, {
|
|
625
685
|
value: listContextValue
|
|
626
686
|
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.GestureDetector, {
|
|
@@ -628,6 +688,7 @@ const ReorderableListCore = ({
|
|
|
628
688
|
}, /*#__PURE__*/_react.default.createElement(AnimatedFlatList, _extends({}, rest, {
|
|
629
689
|
ref: handleRef,
|
|
630
690
|
data: data,
|
|
691
|
+
keyExtractor: keyExtractor,
|
|
631
692
|
CellRendererComponent: renderAnimatedCell,
|
|
632
693
|
onLayout: handleFlatListLayout,
|
|
633
694
|
onScroll: composedScrollHandler,
|