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
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SharedValue } from 'react-native-reanimated';
|
|
3
|
-
import { ReorderableListCellAnimations } from '../types';
|
|
3
|
+
import { ItemLayoutAnimation, ReorderableListCellAnimations } from '../types';
|
|
4
4
|
interface ReorderableListContextData {
|
|
5
5
|
currentIndex: SharedValue<number>;
|
|
6
6
|
draggedHeight: SharedValue<number>;
|
|
7
7
|
dragEndHandlers: SharedValue<((from: number, to: number) => void)[][]>;
|
|
8
8
|
activeIndex: number;
|
|
9
|
+
itemLayoutAnimation: React.MutableRefObject<ItemLayoutAnimation | undefined>;
|
|
9
10
|
cellAnimations: ReorderableListCellAnimations;
|
|
10
11
|
}
|
|
11
12
|
export declare const ReorderableListContext: React.Context<ReorderableListContextData | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReorderableListContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/ReorderableListContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAC,6BAA6B,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ReorderableListContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/ReorderableListContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAC,mBAAmB,EAAE,6BAA6B,EAAC,MAAM,UAAU,CAAC;AAE5E,UAAU,0BAA0B;IAClC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,KAAK,CAAC,gBAAgB,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;IAC7E,cAAc,EAAE,6BAA6B,CAAC;CAC/C;AAED,eAAO,MAAM,sBAAsB,uDAEvB,CAAC"}
|
|
@@ -7,9 +7,9 @@ interface ScrollViewContainerContextData {
|
|
|
7
7
|
scrollViewPageY: SharedValue<number>;
|
|
8
8
|
scrollViewHeightY: SharedValue<number>;
|
|
9
9
|
scrollViewScrollOffsetY: SharedValue<number>;
|
|
10
|
-
|
|
10
|
+
scrollViewScrollEnabledProp: SharedValue<boolean>;
|
|
11
|
+
scrollViewCurrentScrollEnabled: SharedValue<boolean>;
|
|
11
12
|
outerScrollGesture: NativeGesture;
|
|
12
|
-
initialScrollViewScrollEnabled: boolean;
|
|
13
13
|
}
|
|
14
14
|
export declare const ScrollViewContainerContext: React.Context<ScrollViewContainerContextData | undefined>;
|
|
15
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollViewContainerContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/ScrollViewContainerContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAEpD,UAAU,8BAA8B;IACtC,sBAAsB,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACpD,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,
|
|
1
|
+
{"version":3,"file":"ScrollViewContainerContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/ScrollViewContainerContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAEpD,UAAU,8BAA8B;IACtC,sBAAsB,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACpD,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,2BAA2B,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAClD,8BAA8B,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACrD,kBAAkB,EAAE,aAAa,CAAC;CACnC;AAED,eAAO,MAAM,0BAA0B,2DAE3B,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from './useContext';
|
|
2
|
+
export * from './usePropAsSharedValue';
|
|
1
3
|
export * from './useIsActive';
|
|
2
4
|
export * from './useReorderableDrag';
|
|
3
|
-
export * from './useReorderableDragStart';
|
|
4
5
|
export * from './useReorderableDragEnd';
|
|
5
|
-
export * from './
|
|
6
|
+
export * from './useReorderableDragStart';
|
|
7
|
+
export * from './useStableCallback';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePropAsSharedValue.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePropAsSharedValue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAiB,MAAM,yBAAyB,CAAC;AAEpE,eAAO,MAAM,oBAAoB,iCAQhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStableCallback.d.ts","sourceRoot":"","sources":["../../../src/hooks/useStableCallback.ts"],"names":[],"mappings":"AAGA,KAAK,EAAE,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAElC,eAAO,MAAM,iBAAiB,uEAU7B,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
import Animated, { SharedValue } from 'react-native-reanimated';
|
|
2
3
|
export declare enum ReorderableListState {
|
|
3
4
|
IDLE = 0,
|
|
4
5
|
DRAGGED = 1,
|
|
5
6
|
RELEASED = 2,
|
|
6
7
|
AUTOSCROLL = 3
|
|
7
8
|
}
|
|
9
|
+
export type ItemLayoutAnimation = Exclude<ComponentProps<typeof Animated.View>['layout'], undefined>;
|
|
8
10
|
export type SharedValueOrType<T> = {
|
|
9
11
|
[TKey in keyof T]?: SharedValue<T[TKey]> | T[TKey];
|
|
10
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/types/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/types/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAErC,OAAO,QAAQ,EAAE,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAE9D,oBAAY,oBAAoB;IAC9B,IAAI,IAAI;IACR,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,UAAU,IAAA;CACX;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,CACvC,cAAc,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAC9C,SAAS,CACV,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;KAChC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,GACxE;KAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAC,GAAG;KAAE,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK;CAAC,GACvD,KAAK,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FlatListProps, MatrixTransform, PerspectiveTransform, RotateTransform, RotateXTransform, RotateYTransform, RotateZTransform, ScaleTransform, ScaleXTransform, ScaleYTransform, ScrollViewProps, SkewXTransform, SkewYTransform, TranslateXTransform, TranslateYTransform, ViewStyle } from 'react-native';
|
|
2
2
|
import { PanGesture } from 'react-native-gesture-handler';
|
|
3
3
|
import { SharedValue, useAnimatedScrollHandler } from 'react-native-reanimated';
|
|
4
|
-
import { MaximumOneOf, SharedValueOrType } from './misc';
|
|
4
|
+
import { ItemLayoutAnimation, MaximumOneOf, SharedValueOrType } from './misc';
|
|
5
5
|
export interface ReorderableListReorderEvent {
|
|
6
6
|
/**
|
|
7
7
|
* Index of the dragged item.
|
|
@@ -78,6 +78,10 @@ export interface ReorderableListProps<T> extends Omit<FlatListProps<T>, OmittedP
|
|
|
78
78
|
* 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: []}`.
|
|
79
79
|
*/
|
|
80
80
|
cellAnimations?: ReorderableListCellAnimations;
|
|
81
|
+
/**
|
|
82
|
+
* Whether dragging items is enabled. Default: `true`.
|
|
83
|
+
*/
|
|
84
|
+
dragEnabled?: boolean;
|
|
81
85
|
/**
|
|
82
86
|
* Whether the active item should be updated. Enables usage of `useIsActive` hook. Default: `false`.
|
|
83
87
|
*/
|
|
@@ -87,7 +91,7 @@ export interface ReorderableListProps<T> extends Omit<FlatListProps<T>, OmittedP
|
|
|
87
91
|
*/
|
|
88
92
|
panGesture?: PanGesture;
|
|
89
93
|
/**
|
|
90
|
-
*
|
|
94
|
+
* Whether the pan gestures necessary for dragging are enabled. Default: `true`.
|
|
91
95
|
*
|
|
92
96
|
* @deprecated In favor of `panGesture` prop.
|
|
93
97
|
*/
|
|
@@ -98,6 +102,10 @@ export interface ReorderableListProps<T> extends Omit<FlatListProps<T>, OmittedP
|
|
|
98
102
|
* @deprecated In favor of `panGesture` prop.
|
|
99
103
|
*/
|
|
100
104
|
panActivateAfterLongPress?: number;
|
|
105
|
+
/**
|
|
106
|
+
* 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).
|
|
107
|
+
*/
|
|
108
|
+
itemLayoutAnimation?: ItemLayoutAnimation;
|
|
101
109
|
/**
|
|
102
110
|
* Event fired after an item is released and the list is reordered.
|
|
103
111
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/types/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,WAAW,EAAE,wBAAwB,EAAC,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/types/props.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import {useContext} from '../hooks';
|
|
|
7
7
|
import type {NestedReorderableListProps} from '../types';
|
|
8
8
|
|
|
9
9
|
const NestedReorderableListWithRef = <T,>(
|
|
10
|
-
{scrollable,
|
|
10
|
+
{scrollable, ...rest}: NestedReorderableListProps<T>,
|
|
11
11
|
ref?: React.ForwardedRef<FlatList<T>>,
|
|
12
12
|
) => {
|
|
13
13
|
const {
|
|
@@ -15,9 +15,9 @@ const NestedReorderableListWithRef = <T,>(
|
|
|
15
15
|
scrollViewScrollOffsetY,
|
|
16
16
|
scrollViewPageY,
|
|
17
17
|
scrollViewHeightY,
|
|
18
|
-
|
|
18
|
+
scrollViewScrollEnabledProp,
|
|
19
|
+
scrollViewCurrentScrollEnabled,
|
|
19
20
|
outerScrollGesture,
|
|
20
|
-
initialScrollViewScrollEnabled,
|
|
21
21
|
} = useContext(ScrollViewContainerContext);
|
|
22
22
|
|
|
23
23
|
return (
|
|
@@ -29,10 +29,9 @@ const NestedReorderableListWithRef = <T,>(
|
|
|
29
29
|
scrollViewPageY={scrollViewPageY}
|
|
30
30
|
scrollViewHeightY={scrollViewHeightY}
|
|
31
31
|
outerScrollGesture={outerScrollGesture}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
scrollViewScrollEnabledProp={scrollViewScrollEnabledProp}
|
|
33
|
+
scrollViewCurrentScrollEnabled={scrollViewCurrentScrollEnabled}
|
|
34
34
|
scrollable={scrollable}
|
|
35
|
-
scrollEnabled={scrollEnabled}
|
|
36
35
|
nestedScrollEnabled
|
|
37
36
|
/>
|
|
38
37
|
);
|
|
@@ -5,20 +5,19 @@ import {ReorderableListCore} from './ReorderableListCore';
|
|
|
5
5
|
import type {ReorderableListProps} from '../types';
|
|
6
6
|
|
|
7
7
|
const ReorderableListWithRef = <T,>(
|
|
8
|
-
|
|
8
|
+
props: ReorderableListProps<T>,
|
|
9
9
|
ref: React.Ref<FlatList<T>>,
|
|
10
10
|
) => (
|
|
11
11
|
<ReorderableListCore
|
|
12
|
-
{...
|
|
12
|
+
{...props}
|
|
13
13
|
ref={ref}
|
|
14
|
-
scrollEnabled={scrollEnabled}
|
|
15
14
|
scrollViewContainerRef={undefined}
|
|
16
15
|
scrollViewScrollOffsetY={undefined}
|
|
17
16
|
scrollViewPageY={undefined}
|
|
18
17
|
scrollViewHeightY={undefined}
|
|
19
18
|
outerScrollGesture={undefined}
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
scrollViewScrollEnabledProp={undefined}
|
|
20
|
+
scrollViewCurrentScrollEnabled={undefined}
|
|
22
21
|
scrollable
|
|
23
22
|
/>
|
|
24
23
|
);
|
|
@@ -38,8 +38,14 @@ export const ReorderableListCell = memo(
|
|
|
38
38
|
draggedIndex,
|
|
39
39
|
animationDuration,
|
|
40
40
|
}: ReorderableListCellProps<T>) => {
|
|
41
|
-
const {
|
|
42
|
-
|
|
41
|
+
const {
|
|
42
|
+
currentIndex,
|
|
43
|
+
draggedHeight,
|
|
44
|
+
activeIndex,
|
|
45
|
+
cellAnimations,
|
|
46
|
+
itemLayoutAnimation,
|
|
47
|
+
} = useContext(ReorderableListContext);
|
|
48
|
+
|
|
43
49
|
const dragHandler = useCallback(
|
|
44
50
|
() => runOnUI(startDrag)(index),
|
|
45
51
|
[startDrag, index],
|
|
@@ -141,7 +147,10 @@ export const ReorderableListCell = memo(
|
|
|
141
147
|
|
|
142
148
|
return (
|
|
143
149
|
<ReorderableCellContext.Provider value={contextValue}>
|
|
144
|
-
<Animated.View
|
|
150
|
+
<Animated.View
|
|
151
|
+
style={animatedStyle}
|
|
152
|
+
onLayout={handleLayout}
|
|
153
|
+
layout={itemLayoutAnimation.current}>
|
|
145
154
|
{children}
|
|
146
155
|
</Animated.View>
|
|
147
156
|
</ReorderableCellContext.Provider>
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
CellRendererProps,
|
|
4
4
|
FlatList,
|
|
5
5
|
FlatListProps,
|
|
6
|
+
InteractionManager,
|
|
6
7
|
LayoutChangeEvent,
|
|
7
8
|
Platform,
|
|
8
9
|
ScrollView,
|
|
@@ -42,6 +43,7 @@ import {
|
|
|
42
43
|
SCALE_ANIMATION_CONFIG_DEFAULT,
|
|
43
44
|
} from './constants';
|
|
44
45
|
import {ReorderableListCell} from './ReorderableListCell';
|
|
46
|
+
import {usePropAsSharedValue, useStableCallback} from '../hooks';
|
|
45
47
|
|
|
46
48
|
const AnimatedFlatList = Animated.createAnimatedComponent(
|
|
47
49
|
FlatList,
|
|
@@ -55,11 +57,10 @@ interface ReorderableListCoreProps<T> extends ReorderableListProps<T> {
|
|
|
55
57
|
scrollViewPageY: SharedValue<number> | undefined;
|
|
56
58
|
scrollViewHeightY: SharedValue<number> | undefined;
|
|
57
59
|
scrollViewScrollOffsetY: SharedValue<number> | undefined;
|
|
58
|
-
|
|
60
|
+
scrollViewScrollEnabledProp: SharedValue<boolean> | undefined;
|
|
61
|
+
scrollViewCurrentScrollEnabled: SharedValue<boolean> | undefined;
|
|
59
62
|
outerScrollGesture: NativeGesture | undefined;
|
|
60
|
-
initialScrollViewScrollEnabled: boolean | undefined;
|
|
61
63
|
scrollable: boolean | undefined;
|
|
62
|
-
scrollEnabled: boolean | undefined;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
const ReorderableListCore = <T,>(
|
|
@@ -80,31 +81,31 @@ const ReorderableListCore = <T,>(
|
|
|
80
81
|
scrollViewPageY,
|
|
81
82
|
scrollViewHeightY,
|
|
82
83
|
scrollViewScrollOffsetY,
|
|
83
|
-
|
|
84
|
+
scrollViewScrollEnabledProp,
|
|
85
|
+
scrollViewCurrentScrollEnabled,
|
|
84
86
|
scrollable,
|
|
85
87
|
outerScrollGesture,
|
|
86
88
|
cellAnimations,
|
|
89
|
+
dragEnabled = true,
|
|
87
90
|
shouldUpdateActiveItem,
|
|
91
|
+
itemLayoutAnimation,
|
|
88
92
|
panGesture,
|
|
89
93
|
panEnabled = true,
|
|
90
94
|
panActivateAfterLongPress,
|
|
91
95
|
data,
|
|
96
|
+
keyExtractor,
|
|
92
97
|
...rest
|
|
93
98
|
}: ReorderableListCoreProps<T>,
|
|
94
99
|
ref: React.ForwardedRef<FlatList<T>>,
|
|
95
100
|
) => {
|
|
96
|
-
|
|
97
|
-
// but internally we would treat it as false, so we force true.
|
|
98
|
-
const initialScrollEnabled =
|
|
99
|
-
typeof rest.scrollEnabled === 'undefined' ? true : rest.scrollEnabled;
|
|
100
|
-
const initialScrollViewScrollEnabled =
|
|
101
|
-
typeof rest.initialScrollViewScrollEnabled === 'undefined'
|
|
102
|
-
? true
|
|
103
|
-
: rest.initialScrollViewScrollEnabled;
|
|
101
|
+
const scrollEnabled = rest.scrollEnabled ?? true;
|
|
104
102
|
|
|
105
103
|
const flatListRef = useAnimatedRef<FlatList>();
|
|
104
|
+
const markedCellsRef = useRef<Map<string, 1>>();
|
|
106
105
|
const [activeIndex, setActiveIndex] = useState(-1);
|
|
107
|
-
const
|
|
106
|
+
const prevItemCount = useRef(data.length);
|
|
107
|
+
|
|
108
|
+
const currentScrollEnabled = useSharedValue(scrollEnabled);
|
|
108
109
|
const gestureState = useSharedValue<State>(State.UNDETERMINED);
|
|
109
110
|
const currentY = useSharedValue(0);
|
|
110
111
|
const currentTranslationY = useSharedValue(0);
|
|
@@ -137,30 +138,29 @@ const ReorderableListCore = <T,>(
|
|
|
137
138
|
((from: number, to: number) => void)[][]
|
|
138
139
|
>([]);
|
|
139
140
|
const startY = useSharedValue(0);
|
|
140
|
-
const duration = useSharedValue(animationDuration);
|
|
141
141
|
const scaleDefault = useSharedValue(1);
|
|
142
142
|
const opacityDefault = useSharedValue(1);
|
|
143
143
|
const dragDirection = useSharedValue(0);
|
|
144
144
|
const lastDragDirectionPivot = useSharedValue<number | null>(null);
|
|
145
|
-
|
|
146
|
-
const
|
|
145
|
+
|
|
146
|
+
const itemLayoutAnimationPropRef = useRef(itemLayoutAnimation);
|
|
147
|
+
itemLayoutAnimationPropRef.current = itemLayoutAnimation;
|
|
148
|
+
|
|
149
|
+
const keyExtractorPropRef = useRef(keyExtractor);
|
|
150
|
+
keyExtractorPropRef.current = keyExtractor;
|
|
151
|
+
|
|
152
|
+
const scrollEnabledProp = usePropAsSharedValue(scrollEnabled);
|
|
153
|
+
const animationDurationProp = usePropAsSharedValue(animationDuration);
|
|
154
|
+
const autoscrollActivationDeltaProp = usePropAsSharedValue(
|
|
155
|
+
autoscrollActivationDelta,
|
|
156
|
+
);
|
|
157
|
+
const dragEnabledProp = usePropAsSharedValue(dragEnabled ?? true);
|
|
147
158
|
|
|
148
159
|
// Position of the list relative to the scroll container
|
|
149
160
|
const nestedFlatListPositionY = useDerivedValue(
|
|
150
161
|
() => flatListPageY.value - (scrollViewPageY?.value || 0),
|
|
151
162
|
);
|
|
152
163
|
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
duration.value = animationDuration;
|
|
155
|
-
autoscrollDelta.value = autoscrollActivationDelta;
|
|
156
|
-
}, [
|
|
157
|
-
duration,
|
|
158
|
-
animationDuration,
|
|
159
|
-
autoscrollDelta,
|
|
160
|
-
autoscrollActivationDelta,
|
|
161
|
-
itemCount,
|
|
162
|
-
]);
|
|
163
|
-
|
|
164
164
|
useEffect(() => {
|
|
165
165
|
itemCount.value = data.length;
|
|
166
166
|
|
|
@@ -179,6 +179,42 @@ const ReorderableListCore = <T,>(
|
|
|
179
179
|
prevItemCount.current = data.length;
|
|
180
180
|
}, [data.length, itemHeight, itemOffset, itemCount]);
|
|
181
181
|
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (
|
|
184
|
+
!markedCellsRef.current ||
|
|
185
|
+
// Clean keys once they surpass by 10% the size of the list itself.
|
|
186
|
+
markedCellsRef.current.size <= data.length + Math.ceil(data.length * 0.1)
|
|
187
|
+
) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Can be heavy to loop through all items, defer the task to run after interactions.
|
|
192
|
+
const task = InteractionManager.runAfterInteractions(() => {
|
|
193
|
+
if (!markedCellsRef.current) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const map = new Map<string, 1>();
|
|
198
|
+
for (let i = 0; i < data.length; i++) {
|
|
199
|
+
const key = keyExtractorPropRef.current?.(data[i], i) || i.toString();
|
|
200
|
+
if (markedCellsRef.current.has(key)) {
|
|
201
|
+
map.set(key, markedCellsRef.current.get(key)!);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
markedCellsRef.current = map;
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return () => {
|
|
209
|
+
task.cancel();
|
|
210
|
+
};
|
|
211
|
+
}, [data]);
|
|
212
|
+
|
|
213
|
+
const createCellKey = useCallback((cellKey: string) => {
|
|
214
|
+
const mark = markedCellsRef.current?.get(cellKey) || 0;
|
|
215
|
+
return `${cellKey}#${mark}`;
|
|
216
|
+
}, []);
|
|
217
|
+
|
|
182
218
|
const listContextValue = useMemo(
|
|
183
219
|
() => ({
|
|
184
220
|
draggedHeight,
|
|
@@ -186,6 +222,7 @@ const ReorderableListCore = <T,>(
|
|
|
186
222
|
draggedIndex,
|
|
187
223
|
dragEndHandlers,
|
|
188
224
|
activeIndex,
|
|
225
|
+
itemLayoutAnimation: itemLayoutAnimationPropRef,
|
|
189
226
|
cellAnimations: {
|
|
190
227
|
...cellAnimations,
|
|
191
228
|
transform:
|
|
@@ -205,6 +242,7 @@ const ReorderableListCore = <T,>(
|
|
|
205
242
|
dragEndHandlers,
|
|
206
243
|
activeIndex,
|
|
207
244
|
cellAnimations,
|
|
245
|
+
itemLayoutAnimationPropRef,
|
|
208
246
|
scaleDefault,
|
|
209
247
|
opacityDefault,
|
|
210
248
|
],
|
|
@@ -227,14 +265,14 @@ const ReorderableListCore = <T,>(
|
|
|
227
265
|
lastDragDirectionPivot.value = e.absoluteY;
|
|
228
266
|
} else if (
|
|
229
267
|
Math.abs(e.absoluteY - lastDragDirectionPivot.value) >=
|
|
230
|
-
|
|
268
|
+
autoscrollActivationDeltaProp.value
|
|
231
269
|
) {
|
|
232
270
|
dragDirection.value = direction;
|
|
233
271
|
lastDragDirectionPivot.value = e.absoluteY;
|
|
234
272
|
}
|
|
235
273
|
}
|
|
236
274
|
},
|
|
237
|
-
[dragDirection, lastDragDirectionPivot,
|
|
275
|
+
[dragDirection, lastDragDirectionPivot, autoscrollActivationDeltaProp],
|
|
238
276
|
);
|
|
239
277
|
|
|
240
278
|
const setCurrentItemDragCenterY = useCallback(
|
|
@@ -349,30 +387,32 @@ const ReorderableListCore = <T,>(
|
|
|
349
387
|
|
|
350
388
|
const setScrollEnabled = useCallback(
|
|
351
389
|
(enabled: boolean) => {
|
|
352
|
-
//
|
|
353
|
-
if (
|
|
354
|
-
|
|
390
|
+
// When re-enabling the scroll of the flatlist we check whether its prop is set to true.
|
|
391
|
+
if ((enabled && scrollEnabledProp.value) || !enabled) {
|
|
392
|
+
currentScrollEnabled.value = enabled;
|
|
355
393
|
flatListRef.current?.setNativeProps({scrollEnabled: enabled});
|
|
356
394
|
}
|
|
357
395
|
|
|
358
396
|
if (
|
|
359
397
|
scrollViewContainerRef &&
|
|
360
|
-
|
|
361
|
-
|
|
398
|
+
scrollViewScrollEnabledProp &&
|
|
399
|
+
scrollViewCurrentScrollEnabled &&
|
|
400
|
+
// When re-enabling the scroll of the container we check whether its prop is set to true.
|
|
401
|
+
((enabled && scrollViewScrollEnabledProp?.value) || !enabled)
|
|
362
402
|
) {
|
|
363
|
-
|
|
403
|
+
scrollViewCurrentScrollEnabled.value = enabled;
|
|
364
404
|
scrollViewContainerRef.current?.setNativeProps({
|
|
365
405
|
scrollEnabled: enabled,
|
|
366
406
|
});
|
|
367
407
|
}
|
|
368
408
|
},
|
|
369
409
|
[
|
|
370
|
-
initialScrollEnabled,
|
|
371
410
|
flatListRef,
|
|
372
|
-
|
|
373
|
-
|
|
411
|
+
scrollEnabledProp,
|
|
412
|
+
currentScrollEnabled,
|
|
413
|
+
scrollViewScrollEnabledProp,
|
|
414
|
+
scrollViewCurrentScrollEnabled,
|
|
374
415
|
scrollViewContainerRef,
|
|
375
|
-
scrollViewScrollEnabled,
|
|
376
416
|
],
|
|
377
417
|
);
|
|
378
418
|
|
|
@@ -399,12 +439,31 @@ const ReorderableListCore = <T,>(
|
|
|
399
439
|
]);
|
|
400
440
|
|
|
401
441
|
const resetSharedValuesAfterAnimations = useCallback(() => {
|
|
402
|
-
setTimeout(runOnUI(resetSharedValues),
|
|
403
|
-
}, [resetSharedValues,
|
|
442
|
+
setTimeout(runOnUI(resetSharedValues), animationDurationProp.value);
|
|
443
|
+
}, [resetSharedValues, animationDurationProp]);
|
|
444
|
+
|
|
445
|
+
const markCells = (fromIndex: number, toIndex: number) => {
|
|
446
|
+
if (!markedCellsRef.current) {
|
|
447
|
+
markedCellsRef.current = new Map();
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const start = Math.min(fromIndex, toIndex);
|
|
451
|
+
const end = Math.max(fromIndex, toIndex);
|
|
452
|
+
for (let i = start; i <= end; i++) {
|
|
453
|
+
const cellKey = keyExtractorPropRef.current?.(data[i], i) || i.toString();
|
|
454
|
+
if (!markedCellsRef.current.has(cellKey)) {
|
|
455
|
+
markedCellsRef.current.set(cellKey, 1);
|
|
456
|
+
} else {
|
|
457
|
+
markedCellsRef.current.delete(cellKey);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
};
|
|
404
461
|
|
|
405
462
|
const reorder = (fromIndex: number, toIndex: number) => {
|
|
406
463
|
runOnUI(resetSharedValues)();
|
|
407
464
|
|
|
465
|
+
markCells(fromIndex, toIndex);
|
|
466
|
+
|
|
408
467
|
if (fromIndex !== toIndex) {
|
|
409
468
|
onReorder({from: fromIndex, to: toIndex});
|
|
410
469
|
}
|
|
@@ -571,7 +630,7 @@ const ReorderableListCore = <T,>(
|
|
|
571
630
|
dragY.value = withTiming(
|
|
572
631
|
newTopPosition,
|
|
573
632
|
{
|
|
574
|
-
duration:
|
|
633
|
+
duration: animationDurationProp.value,
|
|
575
634
|
easing: Easing.out(Easing.ease),
|
|
576
635
|
},
|
|
577
636
|
() => {
|
|
@@ -799,7 +858,7 @@ const ReorderableListCore = <T,>(
|
|
|
799
858
|
// checking if the list is not scrollable instead of the scrolling state
|
|
800
859
|
// fixes a bug on iOS where the item is shifted after autoscrolling and then
|
|
801
860
|
// moving away from autoscroll area
|
|
802
|
-
if (!
|
|
861
|
+
if (!currentScrollEnabled.value) {
|
|
803
862
|
dragScrollTranslationY.value =
|
|
804
863
|
flatListScrollOffsetY.value - dragInitialScrollOffsetY.value;
|
|
805
864
|
}
|
|
@@ -822,10 +881,10 @@ const ReorderableListCore = <T,>(
|
|
|
822
881
|
useAnimatedReaction(
|
|
823
882
|
() => scrollViewScrollOffsetY?.value,
|
|
824
883
|
value => {
|
|
825
|
-
if (value &&
|
|
884
|
+
if (value && scrollViewCurrentScrollEnabled) {
|
|
826
885
|
// checking if the list is not scrollable instead of the scrolling state
|
|
827
886
|
// fixes a bug on iOS where the item is shifted after autoscrolling and moving away from the area
|
|
828
|
-
if (!
|
|
887
|
+
if (!scrollViewCurrentScrollEnabled.value) {
|
|
829
888
|
scrollViewDragScrollTranslationY.value =
|
|
830
889
|
value - scrollViewDragInitialScrollOffsetY.value;
|
|
831
890
|
}
|
|
@@ -848,6 +907,10 @@ const ReorderableListCore = <T,>(
|
|
|
848
907
|
(index: number) => {
|
|
849
908
|
'worklet';
|
|
850
909
|
|
|
910
|
+
if (!dragEnabledProp.value) {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
|
|
851
914
|
// allow new drag when item is completely released
|
|
852
915
|
if (state.value === ReorderableListState.IDLE) {
|
|
853
916
|
// resetting shared values again fixes a flickeing bug in nested lists where
|
|
@@ -875,6 +938,7 @@ const ReorderableListCore = <T,>(
|
|
|
875
938
|
}
|
|
876
939
|
},
|
|
877
940
|
[
|
|
941
|
+
dragEnabledProp,
|
|
878
942
|
resetSharedValues,
|
|
879
943
|
shouldUpdateActiveItem,
|
|
880
944
|
dragInitialScrollOffsetY,
|
|
@@ -953,21 +1017,20 @@ const ReorderableListCore = <T,>(
|
|
|
953
1017
|
onScroll || null,
|
|
954
1018
|
]);
|
|
955
1019
|
|
|
956
|
-
const renderAnimatedCell =
|
|
1020
|
+
const renderAnimatedCell = useStableCallback(
|
|
957
1021
|
({cellKey, ...props}: CellRendererProps<T>) => (
|
|
958
1022
|
<ReorderableListCell
|
|
959
1023
|
{...props}
|
|
960
1024
|
// forces remount with key change on reorder
|
|
961
|
-
key={
|
|
1025
|
+
key={createCellKey(cellKey)}
|
|
962
1026
|
itemOffset={itemOffset}
|
|
963
1027
|
itemHeight={itemHeight}
|
|
964
1028
|
dragY={dragY}
|
|
965
1029
|
draggedIndex={draggedIndex}
|
|
966
|
-
animationDuration={
|
|
1030
|
+
animationDuration={animationDurationProp}
|
|
967
1031
|
startDrag={startDrag}
|
|
968
1032
|
/>
|
|
969
1033
|
),
|
|
970
|
-
[itemOffset, itemHeight, dragY, draggedIndex, duration, startDrag],
|
|
971
1034
|
);
|
|
972
1035
|
|
|
973
1036
|
return (
|
|
@@ -977,6 +1040,7 @@ const ReorderableListCore = <T,>(
|
|
|
977
1040
|
{...rest}
|
|
978
1041
|
ref={handleRef}
|
|
979
1042
|
data={data}
|
|
1043
|
+
keyExtractor={keyExtractor}
|
|
980
1044
|
CellRendererComponent={renderAnimatedCell}
|
|
981
1045
|
onLayout={handleFlatListLayout}
|
|
982
1046
|
onScroll={composedScrollHandler}
|
|
@@ -11,14 +11,18 @@ import Animated, {
|
|
|
11
11
|
useSharedValue,
|
|
12
12
|
} from 'react-native-reanimated';
|
|
13
13
|
|
|
14
|
-
import {ScrollViewContainerContext} from '../contexts
|
|
14
|
+
import {ScrollViewContainerContext} from '../contexts';
|
|
15
|
+
import {usePropAsSharedValue} from '../hooks';
|
|
15
16
|
import type {ScrollViewContainerProps} from '../types';
|
|
16
17
|
|
|
17
18
|
const ScrollViewContainerWithRef = (
|
|
18
|
-
{onLayout, onScroll,
|
|
19
|
+
{onLayout, onScroll, ...rest}: ScrollViewContainerProps,
|
|
19
20
|
ref: React.ForwardedRef<ScrollView>,
|
|
20
21
|
) => {
|
|
21
|
-
const
|
|
22
|
+
const scrollEnabled = rest.scrollEnabled ?? true;
|
|
23
|
+
|
|
24
|
+
const scrollViewScrollEnabledProp = usePropAsSharedValue(scrollEnabled);
|
|
25
|
+
const scrollViewCurrentScrollEnabled = useSharedValue(scrollEnabled);
|
|
22
26
|
const scrollViewContainerRef = useAnimatedRef<Animated.ScrollView>();
|
|
23
27
|
const scrollViewScrollOffsetY = useSharedValue(0);
|
|
24
28
|
const scrollViewPageY = useSharedValue(0);
|
|
@@ -57,18 +61,18 @@ const ScrollViewContainerWithRef = (
|
|
|
57
61
|
scrollViewPageY,
|
|
58
62
|
scrollViewHeightY,
|
|
59
63
|
scrollViewScrollOffsetY,
|
|
60
|
-
|
|
64
|
+
scrollViewScrollEnabledProp,
|
|
65
|
+
scrollViewCurrentScrollEnabled,
|
|
61
66
|
outerScrollGesture,
|
|
62
|
-
initialScrollViewScrollEnabled: scrollEnabled,
|
|
63
67
|
}),
|
|
64
68
|
[
|
|
65
69
|
scrollViewContainerRef,
|
|
66
70
|
scrollViewPageY,
|
|
67
71
|
scrollViewHeightY,
|
|
68
72
|
scrollViewScrollOffsetY,
|
|
69
|
-
|
|
73
|
+
scrollViewScrollEnabledProp,
|
|
74
|
+
scrollViewCurrentScrollEnabled,
|
|
70
75
|
outerScrollGesture,
|
|
71
|
-
scrollEnabled,
|
|
72
76
|
],
|
|
73
77
|
);
|
|
74
78
|
|
|
@@ -99,7 +103,6 @@ const ScrollViewContainerWithRef = (
|
|
|
99
103
|
ref={handleRef}
|
|
100
104
|
onScroll={composedScrollHandler}
|
|
101
105
|
onLayout={handleLayout}
|
|
102
|
-
scrollEnabled={scrollEnabled}
|
|
103
106
|
/>
|
|
104
107
|
</GestureDetector>
|
|
105
108
|
</ScrollViewContainerContext.Provider>
|