react-native-reorderable-list 0.16.1 → 0.17.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 +12 -5
- package/lib/commonjs/components/NestedReorderableList.js +6 -6
- package/lib/commonjs/components/NestedReorderableList.js.map +1 -1
- package/lib/commonjs/components/ReorderableList.js +3 -3
- package/lib/commonjs/components/ReorderableList.js.map +1 -1
- package/lib/commonjs/components/ReorderableListCell.js +20 -18
- package/lib/commonjs/components/ReorderableListCell.js.map +1 -1
- package/lib/commonjs/components/ReorderableListCore.js +169 -159
- package/lib/commonjs/components/ReorderableListCore.js.map +1 -1
- package/lib/commonjs/components/ScrollViewContainer.js +13 -12
- package/lib/commonjs/components/ScrollViewContainer.js.map +1 -1
- package/lib/commonjs/contexts/ReorderableListContext.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/NestedReorderableList.js +6 -6
- package/lib/module/components/NestedReorderableList.js.map +1 -1
- package/lib/module/components/ReorderableList.js +3 -3
- package/lib/module/components/ReorderableList.js.map +1 -1
- package/lib/module/components/ReorderableListCell.js +20 -18
- package/lib/module/components/ReorderableListCell.js.map +1 -1
- package/lib/module/components/ReorderableListCore.js +169 -159
- package/lib/module/components/ReorderableListCore.js.map +1 -1
- package/lib/module/components/ScrollViewContainer.js +13 -12
- package/lib/module/components/ScrollViewContainer.js.map +1 -1
- package/lib/module/contexts/ReorderableListContext.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/ReorderableListCell.d.ts +3 -3
- package/lib/typescript/components/ReorderableListCell.d.ts.map +1 -1
- package/lib/typescript/components/ReorderableListCore.d.ts +3 -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 +3 -3
- package/lib/typescript/contexts/ScrollViewContainerContext.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/props.d.ts +18 -4
- package/lib/typescript/types/props.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/NestedReorderableList.tsx +6 -6
- package/src/components/ReorderableList.tsx +3 -3
- package/src/components/ReorderableListCell.tsx +27 -19
- package/src/components/ReorderableListCore.tsx +278 -219
- package/src/components/ScrollViewContainer.tsx +27 -14
- package/src/contexts/ReorderableListContext.ts +2 -1
- package/src/contexts/ScrollViewContainerContext.ts +3 -3
- package/src/index.ts +2 -0
- package/src/types/props.ts +24 -5
|
@@ -25,9 +25,10 @@ const ScrollViewContainerWithRef = (
|
|
|
25
25
|
useState(false);
|
|
26
26
|
const scrollViewScrollEnabledProp = usePropAsSharedValue(scrollEnabled);
|
|
27
27
|
const scrollViewContainerRef = useAnimatedRef<Animated.ScrollView>();
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
28
|
+
const scrollViewScrollOffsetXY = useSharedValue(0);
|
|
29
|
+
const scrollViewPageXY = useSharedValue(0);
|
|
30
|
+
const scrollViewSize = useSharedValue(0);
|
|
31
|
+
const horizontalProp = usePropAsSharedValue(!!rest.horizontal);
|
|
31
32
|
|
|
32
33
|
const handleRef = useCallback(
|
|
33
34
|
(value: Animated.ScrollView) => {
|
|
@@ -46,9 +47,11 @@ const ScrollViewContainerWithRef = (
|
|
|
46
47
|
|
|
47
48
|
const handleScroll = useAnimatedScrollHandler(
|
|
48
49
|
e => {
|
|
49
|
-
|
|
50
|
+
scrollViewScrollOffsetXY.value = horizontalProp.value
|
|
51
|
+
? e.contentOffset.x
|
|
52
|
+
: e.contentOffset.y;
|
|
50
53
|
},
|
|
51
|
-
[
|
|
54
|
+
[scrollViewScrollOffsetXY],
|
|
52
55
|
);
|
|
53
56
|
|
|
54
57
|
const composedScrollHandler = useComposedEventHandler([
|
|
@@ -59,18 +62,18 @@ const ScrollViewContainerWithRef = (
|
|
|
59
62
|
const contextValue = useMemo(
|
|
60
63
|
() => ({
|
|
61
64
|
scrollViewContainerRef,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
scrollViewPageXY,
|
|
66
|
+
scrollViewSize,
|
|
67
|
+
scrollViewScrollOffsetXY,
|
|
65
68
|
scrollViewScrollEnabledProp,
|
|
66
69
|
outerScrollGesture,
|
|
67
70
|
setScrollViewForceDisableScroll,
|
|
68
71
|
}),
|
|
69
72
|
[
|
|
70
73
|
scrollViewContainerRef,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
scrollViewPageXY,
|
|
75
|
+
scrollViewSize,
|
|
76
|
+
scrollViewScrollOffsetXY,
|
|
74
77
|
scrollViewScrollEnabledProp,
|
|
75
78
|
outerScrollGesture,
|
|
76
79
|
setScrollViewForceDisableScroll,
|
|
@@ -79,7 +82,9 @@ const ScrollViewContainerWithRef = (
|
|
|
79
82
|
|
|
80
83
|
const handleLayout = useCallback(
|
|
81
84
|
(e: LayoutChangeEvent) => {
|
|
82
|
-
|
|
85
|
+
scrollViewSize.value = horizontalProp.value
|
|
86
|
+
? e.nativeEvent.layout.width
|
|
87
|
+
: e.nativeEvent.layout.height;
|
|
83
88
|
|
|
84
89
|
// measuring pageY allows wrapping nested lists in other views
|
|
85
90
|
runOnUI(() => {
|
|
@@ -88,12 +93,20 @@ const ScrollViewContainerWithRef = (
|
|
|
88
93
|
return;
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
|
|
96
|
+
scrollViewPageXY.value = horizontalProp.value
|
|
97
|
+
? measurement.pageX
|
|
98
|
+
: measurement.pageY;
|
|
92
99
|
})();
|
|
93
100
|
|
|
94
101
|
onLayout?.(e);
|
|
95
102
|
},
|
|
96
|
-
[
|
|
103
|
+
[
|
|
104
|
+
onLayout,
|
|
105
|
+
scrollViewContainerRef,
|
|
106
|
+
scrollViewSize,
|
|
107
|
+
scrollViewPageXY,
|
|
108
|
+
horizontalProp,
|
|
109
|
+
],
|
|
97
110
|
);
|
|
98
111
|
|
|
99
112
|
return (
|
|
@@ -6,11 +6,12 @@ import {ItemLayoutAnimation, ReorderableListCellAnimations} from '../types';
|
|
|
6
6
|
|
|
7
7
|
interface ReorderableListContextData {
|
|
8
8
|
currentIndex: SharedValue<number>;
|
|
9
|
-
|
|
9
|
+
draggedSize: SharedValue<number>;
|
|
10
10
|
dragEndHandlers: SharedValue<((from: number, to: number) => void)[][]>;
|
|
11
11
|
activeIndex: number;
|
|
12
12
|
itemLayoutAnimation: React.MutableRefObject<ItemLayoutAnimation | undefined>;
|
|
13
13
|
cellAnimations: ReorderableListCellAnimations;
|
|
14
|
+
horizontal: SharedValue<boolean>;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export const ReorderableListContext = React.createContext<
|
|
@@ -6,9 +6,9 @@ import {SharedValue} from 'react-native-reanimated';
|
|
|
6
6
|
|
|
7
7
|
interface ScrollViewContainerContextData {
|
|
8
8
|
scrollViewContainerRef: React.RefObject<ScrollView>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
scrollViewPageXY: SharedValue<number>;
|
|
10
|
+
scrollViewSize: SharedValue<number>;
|
|
11
|
+
scrollViewScrollOffsetXY: SharedValue<number>;
|
|
12
12
|
scrollViewScrollEnabledProp: SharedValue<boolean>;
|
|
13
13
|
outerScrollGesture: NativeGesture;
|
|
14
14
|
setScrollViewForceDisableScroll: Dispatch<SetStateAction<boolean>>;
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
useReorderableDragStart,
|
|
11
11
|
} from './hooks';
|
|
12
12
|
import type {
|
|
13
|
+
NestedReorderableListProps,
|
|
13
14
|
ReorderableListCellAnimations,
|
|
14
15
|
ReorderableListDragEndEvent,
|
|
15
16
|
ReorderableListDragStartEvent,
|
|
@@ -25,6 +26,7 @@ export {
|
|
|
25
26
|
useReorderableDrag,
|
|
26
27
|
useReorderableDragStart,
|
|
27
28
|
useReorderableDragEnd,
|
|
29
|
+
NestedReorderableListProps,
|
|
28
30
|
ReorderableListProps,
|
|
29
31
|
ReorderableListReorderEvent,
|
|
30
32
|
ReorderableListCellAnimations,
|
package/src/types/props.ts
CHANGED
|
@@ -59,7 +59,6 @@ export interface ReorderableListDragEndEvent {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
type OmittedProps =
|
|
62
|
-
| 'horizontal'
|
|
63
62
|
| 'onScroll'
|
|
64
63
|
| 'scrollEventThrottle'
|
|
65
64
|
| 'removeClippedSubviews'
|
|
@@ -71,15 +70,35 @@ export interface ReorderableListProps<T>
|
|
|
71
70
|
data: T[];
|
|
72
71
|
/**
|
|
73
72
|
* Threshold at the extremety of the list which triggers autoscroll when an item is dragged to it.
|
|
74
|
-
* A value of 0.1 means that 10% of the area at the
|
|
73
|
+
* A value of 0.1 means that 10% of the area at the start and 10% at the end of the list will trigger autoscroll
|
|
75
74
|
* when an item is dragged to it. Min value: `0`. Max value: `0.4`. Default: `0.1`.
|
|
76
75
|
*/
|
|
77
76
|
autoscrollThreshold?: number;
|
|
78
77
|
/**
|
|
79
|
-
* Amount by which the threshold is offset at the
|
|
80
|
-
* For example, setting `{
|
|
78
|
+
* Amount by which the threshold is offset at the extremity of the list.
|
|
79
|
+
* For example, setting `{start: 50}` will make the autoscroll trigger 50 pixels earlier at the start of the list.
|
|
81
80
|
*/
|
|
82
|
-
autoscrollThresholdOffset?: {
|
|
81
|
+
autoscrollThresholdOffset?: {
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Use `start` instead.
|
|
84
|
+
*/
|
|
85
|
+
top?: number;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use `end` instead.
|
|
89
|
+
*/
|
|
90
|
+
bottom?: number;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Offset from the start of the list.
|
|
94
|
+
*/
|
|
95
|
+
start?: number;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Offset from the end of the list.
|
|
99
|
+
*/
|
|
100
|
+
end?: number;
|
|
101
|
+
};
|
|
83
102
|
/**
|
|
84
103
|
* Scales the autoscroll spreed at which the list scrolls when an item is dragged to the scroll areas. Default: `1`.
|
|
85
104
|
*/
|