react-native-reorderable-list 0.6.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +28 -3
  2. package/lib/commonjs/components/NestedReorderableList.js +41 -0
  3. package/lib/commonjs/components/NestedReorderableList.js.map +1 -0
  4. package/lib/commonjs/components/ReorderableList.js +29 -0
  5. package/lib/commonjs/components/ReorderableList.js.map +1 -0
  6. package/lib/commonjs/components/ReorderableListCell.js +1 -3
  7. package/lib/commonjs/components/ReorderableListCell.js.map +1 -1
  8. package/lib/commonjs/components/{ReorderableList/ReorderableList.js → ReorderableListCore/ReorderableListCore.js} +35 -10
  9. package/lib/commonjs/components/ReorderableListCore/ReorderableListCore.js.map +1 -0
  10. package/lib/commonjs/components/ReorderableListCore/constants.js +31 -0
  11. package/lib/commonjs/components/ReorderableListCore/constants.js.map +1 -0
  12. package/lib/commonjs/components/ReorderableListCore/index.js +17 -0
  13. package/lib/commonjs/components/ReorderableListCore/index.js.map +1 -0
  14. package/lib/commonjs/components/{ReorderableList/useReorderableList.js → ReorderableListCore/useReorderableListCore.js} +176 -70
  15. package/lib/commonjs/components/ReorderableListCore/useReorderableListCore.js.map +1 -0
  16. package/lib/commonjs/components/ScrollViewContainer.js +53 -0
  17. package/lib/commonjs/components/ScrollViewContainer.js.map +1 -0
  18. package/lib/commonjs/components/index.js +22 -0
  19. package/lib/commonjs/components/index.js.map +1 -1
  20. package/lib/commonjs/contexts/ScrollViewContainerContext.js +10 -0
  21. package/lib/commonjs/contexts/ScrollViewContainerContext.js.map +1 -0
  22. package/lib/commonjs/contexts/index.js +11 -0
  23. package/lib/commonjs/contexts/index.js.map +1 -1
  24. package/lib/commonjs/index.js +12 -0
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/module/components/NestedReorderableList.js +33 -0
  27. package/lib/module/components/NestedReorderableList.js.map +1 -0
  28. package/lib/module/components/ReorderableList.js +21 -0
  29. package/lib/module/components/ReorderableList.js.map +1 -0
  30. package/lib/module/components/ReorderableListCell.js +1 -3
  31. package/lib/module/components/ReorderableListCell.js.map +1 -1
  32. package/lib/module/components/{ReorderableList/ReorderableList.js → ReorderableListCore/ReorderableListCore.js} +39 -14
  33. package/lib/module/components/ReorderableListCore/ReorderableListCore.js.map +1 -0
  34. package/lib/module/components/ReorderableListCore/constants.js +25 -0
  35. package/lib/module/components/ReorderableListCore/constants.js.map +1 -0
  36. package/lib/module/components/ReorderableListCore/index.js +2 -0
  37. package/lib/module/components/ReorderableListCore/index.js.map +1 -0
  38. package/lib/module/components/{ReorderableList/useReorderableList.js → ReorderableListCore/useReorderableListCore.js} +177 -71
  39. package/lib/module/components/ReorderableListCore/useReorderableListCore.js.map +1 -0
  40. package/lib/module/components/ScrollViewContainer.js +44 -0
  41. package/lib/module/components/ScrollViewContainer.js.map +1 -0
  42. package/lib/module/components/index.js +2 -0
  43. package/lib/module/components/index.js.map +1 -1
  44. package/lib/module/contexts/ScrollViewContainerContext.js +3 -0
  45. package/lib/module/contexts/ScrollViewContainerContext.js.map +1 -0
  46. package/lib/module/contexts/index.js +1 -0
  47. package/lib/module/contexts/index.js.map +1 -1
  48. package/lib/module/index.js +2 -2
  49. package/lib/module/index.js.map +1 -1
  50. package/lib/typescript/components/NestedReorderableList.d.ts +5 -0
  51. package/lib/typescript/components/NestedReorderableList.d.ts.map +1 -0
  52. package/lib/typescript/components/ReorderableList.d.ts +5 -0
  53. package/lib/typescript/components/ReorderableList.d.ts.map +1 -0
  54. package/lib/typescript/components/ReorderableListCell.d.ts.map +1 -1
  55. package/lib/typescript/components/ReorderableListCore/ReorderableListCore.d.ts +20 -0
  56. package/lib/typescript/components/ReorderableListCore/ReorderableListCore.d.ts.map +1 -0
  57. package/lib/typescript/components/ReorderableListCore/constants.d.ts +6 -0
  58. package/lib/typescript/components/ReorderableListCore/constants.d.ts.map +1 -0
  59. package/lib/typescript/components/ReorderableListCore/index.d.ts +2 -0
  60. package/lib/typescript/components/ReorderableListCore/index.d.ts.map +1 -0
  61. package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts +44 -0
  62. package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts.map +1 -0
  63. package/lib/typescript/components/ScrollViewContainer.d.ts +4 -0
  64. package/lib/typescript/components/ScrollViewContainer.d.ts.map +1 -0
  65. package/lib/typescript/components/index.d.ts +2 -0
  66. package/lib/typescript/components/index.d.ts.map +1 -1
  67. package/lib/typescript/contexts/ScrollViewContainerContext.d.ts +15 -0
  68. package/lib/typescript/contexts/ScrollViewContainerContext.d.ts.map +1 -0
  69. package/lib/typescript/contexts/index.d.ts +1 -0
  70. package/lib/typescript/contexts/index.d.ts.map +1 -1
  71. package/lib/typescript/index.d.ts +3 -3
  72. package/lib/typescript/index.d.ts.map +1 -1
  73. package/lib/typescript/types/props.d.ts +13 -1
  74. package/lib/typescript/types/props.d.ts.map +1 -1
  75. package/package.json +15 -7
  76. package/src/components/NestedReorderableList.tsx +43 -0
  77. package/src/components/ReorderableList.tsx +29 -0
  78. package/src/components/ReorderableListCell.tsx +1 -3
  79. package/src/components/ReorderableListCore/ReorderableListCore.tsx +162 -0
  80. package/src/components/ReorderableListCore/constants.ts +31 -0
  81. package/src/components/ReorderableListCore/index.ts +1 -0
  82. package/src/components/{ReorderableList/useReorderableList.ts → ReorderableListCore/useReorderableListCore.ts} +261 -89
  83. package/src/components/ScrollViewContainer.tsx +74 -0
  84. package/src/components/index.ts +2 -0
  85. package/src/contexts/ScrollViewContainerContext.ts +18 -0
  86. package/src/contexts/index.ts +1 -0
  87. package/src/index.ts +10 -1
  88. package/src/types/props.ts +21 -1
  89. package/lib/commonjs/components/ReorderableList/ReorderableList.js.map +0 -1
  90. package/lib/commonjs/components/ReorderableList/constants.ios.js +0 -10
  91. package/lib/commonjs/components/ReorderableList/constants.ios.js.map +0 -1
  92. package/lib/commonjs/components/ReorderableList/constants.js +0 -10
  93. package/lib/commonjs/components/ReorderableList/constants.js.map +0 -1
  94. package/lib/commonjs/components/ReorderableList/index.js +0 -17
  95. package/lib/commonjs/components/ReorderableList/index.js.map +0 -1
  96. package/lib/commonjs/components/ReorderableList/useReorderableList.js.map +0 -1
  97. package/lib/module/components/ReorderableList/ReorderableList.js.map +0 -1
  98. package/lib/module/components/ReorderableList/constants.ios.js +0 -4
  99. package/lib/module/components/ReorderableList/constants.ios.js.map +0 -1
  100. package/lib/module/components/ReorderableList/constants.js +0 -4
  101. package/lib/module/components/ReorderableList/constants.js.map +0 -1
  102. package/lib/module/components/ReorderableList/index.js +0 -2
  103. package/lib/module/components/ReorderableList/index.js.map +0 -1
  104. package/lib/module/components/ReorderableList/useReorderableList.js.map +0 -1
  105. package/lib/typescript/components/ReorderableList/ReorderableList.d.ts +0 -8
  106. package/lib/typescript/components/ReorderableList/ReorderableList.d.ts.map +0 -1
  107. package/lib/typescript/components/ReorderableList/constants.d.ts +0 -3
  108. package/lib/typescript/components/ReorderableList/constants.d.ts.map +0 -1
  109. package/lib/typescript/components/ReorderableList/constants.ios.d.ts +0 -3
  110. package/lib/typescript/components/ReorderableList/constants.ios.d.ts.map +0 -1
  111. package/lib/typescript/components/ReorderableList/index.d.ts +0 -2
  112. package/lib/typescript/components/ReorderableList/index.d.ts.map +0 -1
  113. package/lib/typescript/components/ReorderableList/useReorderableList.d.ts +0 -36
  114. package/lib/typescript/components/ReorderableList/useReorderableList.d.ts.map +0 -1
  115. package/src/components/ReorderableList/ReorderableList.tsx +0 -109
  116. package/src/components/ReorderableList/constants.ios.ts +0 -3
  117. package/src/components/ReorderableList/constants.ts +0 -3
  118. package/src/components/ReorderableList/index.ts +0 -1
@@ -0,0 +1,33 @@
1
+ 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); }
2
+ import React, { forwardRef } from 'react';
3
+ import { ReorderableListCore } from './ReorderableListCore';
4
+ import { ScrollViewContainerContext } from '../contexts';
5
+ import { useContext } from '../hooks';
6
+ const NestedReorderableListWithRef = ({
7
+ scrollable,
8
+ scrollEnabled = true,
9
+ ...rest
10
+ }, ref) => {
11
+ const {
12
+ scrollViewContainerRef,
13
+ scrollViewScrollOffsetY,
14
+ scrollViewHeightY,
15
+ scrollViewScrollEnabled,
16
+ outerScrollGesture,
17
+ initialScrollViewScrollEnabled
18
+ } = useContext(ScrollViewContainerContext);
19
+ return /*#__PURE__*/React.createElement(ReorderableListCore, _extends({}, rest, {
20
+ ref: ref,
21
+ scrollViewContainerRef: scrollViewContainerRef,
22
+ scrollViewScrollOffsetY: scrollViewScrollOffsetY,
23
+ scrollViewHeightY: scrollViewHeightY,
24
+ outerScrollGesture: outerScrollGesture,
25
+ scrollViewScrollEnabled: scrollViewScrollEnabled,
26
+ initialScrollViewScrollEnabled: initialScrollViewScrollEnabled,
27
+ scrollable: scrollable,
28
+ scrollEnabled: scrollEnabled,
29
+ nestedScrollEnabled: true
30
+ }));
31
+ };
32
+ export const NestedReorderableList = /*#__PURE__*/forwardRef(NestedReorderableListWithRef);
33
+ //# sourceMappingURL=NestedReorderableList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","ReorderableListCore","ScrollViewContainerContext","useContext","NestedReorderableListWithRef","scrollable","scrollEnabled","rest","ref","scrollViewContainerRef","scrollViewScrollOffsetY","scrollViewHeightY","scrollViewScrollEnabled","outerScrollGesture","initialScrollViewScrollEnabled","createElement","_extends","nestedScrollEnabled","NestedReorderableList"],"sourceRoot":"../../../src","sources":["components/NestedReorderableList.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAGC,UAAU,QAAO,OAAO;AAGvC,SAAQC,mBAAmB,QAAO,uBAAuB;AACzD,SAAQC,0BAA0B,QAAO,aAAa;AACtD,SAAQC,UAAU,QAAO,UAAU;AAGnC,MAAMC,4BAA4B,GAAGA,CACnC;EAACC,UAAU;EAAEC,aAAa,GAAG,IAAI;EAAE,GAAGC;AAAmC,CAAC,EAC1EC,GAAqC,KAClC;EACH,MAAM;IACJC,sBAAsB;IACtBC,uBAAuB;IACvBC,iBAAiB;IACjBC,uBAAuB;IACvBC,kBAAkB;IAClBC;EACF,CAAC,GAAGX,UAAU,CAACD,0BAA0B,CAAC;EAE1C,oBACEH,KAAA,CAAAgB,aAAA,CAACd,mBAAmB,EAAAe,QAAA,KACdT,IAAI;IACRC,GAAG,EAAEA,GAAI;IACTC,sBAAsB,EAAEA,sBAAuB;IAC/CC,uBAAuB,EAAEA,uBAAwB;IACjDC,iBAAiB,EAAEA,iBAAkB;IACrCE,kBAAkB,EAAEA,kBAAmB;IACvCD,uBAAuB,EAAEA,uBAAwB;IACjDE,8BAA8B,EAAEA,8BAA+B;IAC/DT,UAAU,EAAEA,UAAW;IACvBC,aAAa,EAAEA,aAAc;IAC7BW,mBAAmB;EAAA,EACpB,CAAC;AAEN,CAAC;AAED,OAAO,MAAMC,qBAAqB,gBAAGlB,UAAU,CAC7CI,4BACF,CAEgB","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ 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); }
2
+ import React, { forwardRef } from 'react';
3
+ import { ReorderableListCore } from './ReorderableListCore';
4
+ const ReorderableListWithRef = ({
5
+ scrollEnabled = true,
6
+ ...rest
7
+ }, ref) => {
8
+ return /*#__PURE__*/React.createElement(ReorderableListCore, _extends({}, rest, {
9
+ ref: ref,
10
+ scrollEnabled: scrollEnabled,
11
+ initialScrollViewScrollEnabled: true,
12
+ scrollable: true,
13
+ scrollViewContainerRef: undefined,
14
+ scrollViewScrollOffsetY: undefined,
15
+ scrollViewHeightY: undefined,
16
+ outerScrollGesture: undefined,
17
+ scrollViewScrollEnabled: undefined
18
+ }));
19
+ };
20
+ export const ReorderableList = /*#__PURE__*/forwardRef(ReorderableListWithRef);
21
+ //# sourceMappingURL=ReorderableList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","ReorderableListCore","ReorderableListWithRef","scrollEnabled","rest","ref","createElement","_extends","initialScrollViewScrollEnabled","scrollable","scrollViewContainerRef","undefined","scrollViewScrollOffsetY","scrollViewHeightY","outerScrollGesture","scrollViewScrollEnabled","ReorderableList"],"sourceRoot":"../../../src","sources":["components/ReorderableList.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAGC,UAAU,QAAO,OAAO;AAGvC,SAAQC,mBAAmB,QAAO,uBAAuB;AAGzD,MAAMC,sBAAsB,GAAGA,CAC7B;EAACC,aAAa,GAAG,IAAI;EAAE,GAAGC;AAA6B,CAAC,EACxDC,GAA2B,KACxB;EACH,oBACEN,KAAA,CAAAO,aAAA,CAACL,mBAAmB,EAAAM,QAAA,KACdH,IAAI;IACRC,GAAG,EAAEA,GAAI;IACTF,aAAa,EAAEA,aAAc;IAC7BK,8BAA8B,EAAE,IAAK;IACrCC,UAAU,EAAE,IAAK;IACjBC,sBAAsB,EAAEC,SAAU;IAClCC,uBAAuB,EAAED,SAAU;IACnCE,iBAAiB,EAAEF,SAAU;IAC7BG,kBAAkB,EAAEH,SAAU;IAC9BI,uBAAuB,EAAEJ;EAAU,EACpC,CAAC;AAEN,CAAC;AAED,OAAO,MAAMK,eAAe,gBAAGhB,UAAU,CAACE,sBAAsB,CAEhD","ignoreList":[]}
@@ -69,9 +69,7 @@ export const ReorderableListCell = /*#__PURE__*/memo(({
69
69
  itemOffset.value[index] = y;
70
70
  itemHeight.value[index] = height;
71
71
  })(e.nativeEvent.layout.y, e.nativeEvent.layout.height);
72
- if (onLayout) {
73
- onLayout(e);
74
- }
72
+ onLayout === null || onLayout === void 0 || onLayout(e);
75
73
  };
76
74
  return /*#__PURE__*/React.createElement(ReorderableCellContext.Provider, {
77
75
  value: contextValue
@@ -1 +1 @@
1
- {"version":3,"names":["React","memo","useCallback","useMemo","Animated","Easing","runOnUI","useAnimatedReaction","useAnimatedStyle","useSharedValue","withTiming","ReorderableCellContext","ReorderableListContext","useContext","ReorderableListCell","index","startDrag","children","onLayout","itemOffset","itemHeight","dragY","draggedIndex","animationDuration","dragHandler","contextValue","currentIndex","draggedHeight","itemZIndex","itemPositionY","itemDragY","itemIndex","value","moveDown","startMove","Math","min","endMove","max","newValue","duration","easing","out","ease","animatedStyle","zIndex","transform","translateY","handleLayout","e","y","height","nativeEvent","layout","createElement","Provider","View","style"],"sourceRoot":"../../../src","sources":["components/ReorderableListCell.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAGC,IAAI,EAAEC,WAAW,EAAEC,OAAO,QAAO,OAAO;AAGvD,OAAOC,QAAQ,IACbC,MAAM,EAENC,OAAO,EACPC,mBAAmB,EACnBC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAAQC,sBAAsB,EAAEC,sBAAsB,QAAO,aAAa;AAC1E,SAAQC,UAAU,QAAO,UAAU;AAanC,OAAO,MAAMC,mBAAmB,gBAAGb,IAAI,CACrC,CAAK;EACHc,KAAK;EACLC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRC,UAAU;EACVC,UAAU;EACVC,KAAK;EACLC,YAAY;EACZC;AAC2B,CAAC,KAAK;EACjC,MAAMC,WAAW,GAAGtB,WAAW,CAAC,MAAM;IACpC,SAAS;;IAETc,SAAS,CAACD,KAAK,CAAC;EAClB,CAAC,EAAE,CAACC,SAAS,EAAED,KAAK,CAAC,CAAC;EAEtB,MAAMU,YAAY,GAAGtB,OAAO,CAC1B,OAAO;IACLY,KAAK;IACLS,WAAW;IACXF;EACF,CAAC,CAAC,EACF,CAACP,KAAK,EAAES,WAAW,EAAEF,YAAY,CACnC,CAAC;EACD,MAAM;IAACI,YAAY;IAAEC;EAAa,CAAC,GAAGd,UAAU,CAACD,sBAAsB,CAAC;EAExE,MAAMgB,UAAU,GAAGnB,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":[]}
1
+ {"version":3,"names":["React","memo","useCallback","useMemo","Animated","Easing","runOnUI","useAnimatedReaction","useAnimatedStyle","useSharedValue","withTiming","ReorderableCellContext","ReorderableListContext","useContext","ReorderableListCell","index","startDrag","children","onLayout","itemOffset","itemHeight","dragY","draggedIndex","animationDuration","dragHandler","contextValue","currentIndex","draggedHeight","itemZIndex","itemPositionY","itemDragY","itemIndex","value","moveDown","startMove","Math","min","endMove","max","newValue","duration","easing","out","ease","animatedStyle","zIndex","transform","translateY","handleLayout","e","y","height","nativeEvent","layout","createElement","Provider","View","style"],"sourceRoot":"../../../src","sources":["components/ReorderableListCell.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAGC,IAAI,EAAEC,WAAW,EAAEC,OAAO,QAAO,OAAO;AAGvD,OAAOC,QAAQ,IACbC,MAAM,EAENC,OAAO,EACPC,mBAAmB,EACnBC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAAQC,sBAAsB,EAAEC,sBAAsB,QAAO,aAAa;AAC1E,SAAQC,UAAU,QAAO,UAAU;AAanC,OAAO,MAAMC,mBAAmB,gBAAGb,IAAI,CACrC,CAAK;EACHc,KAAK;EACLC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRC,UAAU;EACVC,UAAU;EACVC,KAAK;EACLC,YAAY;EACZC;AAC2B,CAAC,KAAK;EACjC,MAAMC,WAAW,GAAGtB,WAAW,CAAC,MAAM;IACpC,SAAS;;IAETc,SAAS,CAACD,KAAK,CAAC;EAClB,CAAC,EAAE,CAACC,SAAS,EAAED,KAAK,CAAC,CAAC;EAEtB,MAAMU,YAAY,GAAGtB,OAAO,CAC1B,OAAO;IACLY,KAAK;IACLS,WAAW;IACXF;EACF,CAAC,CAAC,EACF,CAACP,KAAK,EAAES,WAAW,EAAEF,YAAY,CACnC,CAAC;EACD,MAAM;IAACI,YAAY;IAAEC;EAAa,CAAC,GAAGd,UAAU,CAACD,sBAAsB,CAAC;EAExE,MAAMgB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CAAC","ignoreList":[]}
@@ -1,18 +1,18 @@
1
1
  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); }
2
- import React, { useCallback } from 'react';
3
- import { FlatList } from 'react-native';
4
- import { GestureDetector } from 'react-native-gesture-handler';
2
+ import React, { useCallback, useMemo } from 'react';
3
+ import { FlatList, Platform } from 'react-native';
4
+ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
5
5
  import Animated from 'react-native-reanimated';
6
- import { AUTOSCROLL_DELAY } from './constants';
7
- import { useReorderableList } from './useReorderableList';
6
+ import { AUTOSCROLL_CONFIG } from './constants';
7
+ import { useReorderableListCore } from './useReorderableListCore';
8
8
  import { ReorderableListContext } from '../../contexts';
9
9
  import { ReorderableListCell } from '../ReorderableListCell';
10
10
  const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
11
- const ReorderableList = ({
11
+ const ReorderableListCore = ({
12
12
  data,
13
13
  autoscrollThreshold = 0.1,
14
14
  autoscrollSpeedScale = 1,
15
- autoscrollDelay = AUTOSCROLL_DELAY,
15
+ autoscrollDelay = AUTOSCROLL_CONFIG.delay,
16
16
  animationDuration = 200,
17
17
  dragReorderThreshold = 0.2,
18
18
  onLayout,
@@ -21,6 +21,14 @@ const ReorderableList = ({
21
21
  onDragEnd,
22
22
  keyExtractor,
23
23
  extraData,
24
+ scrollViewContainerRef,
25
+ scrollViewHeightY,
26
+ scrollViewScrollOffsetY,
27
+ scrollViewScrollEnabled,
28
+ scrollEnabled,
29
+ initialScrollViewScrollEnabled,
30
+ scrollable,
31
+ outerScrollGesture,
24
32
  ...rest
25
33
  }, ref) => {
26
34
  const {
@@ -35,7 +43,7 @@ const ReorderableList = ({
35
43
  dragY,
36
44
  draggedIndex,
37
45
  duration
38
- } = useReorderableList({
46
+ } = useReorderableListCore({
39
47
  ref,
40
48
  autoscrollThreshold,
41
49
  autoscrollSpeedScale,
@@ -45,8 +53,24 @@ const ReorderableList = ({
45
53
  onLayout,
46
54
  onReorder,
47
55
  onScroll,
48
- onDragEnd
56
+ onDragEnd,
57
+ scrollViewContainerRef,
58
+ scrollViewHeightY,
59
+ scrollViewScrollOffsetY,
60
+ scrollViewScrollEnabled,
61
+ // flatlist will default to true if we pass explicitly undefined,
62
+ // but internally we would treat it as false, so we force true
63
+ initialScrollEnabled: typeof scrollEnabled === 'undefined' ? true : scrollEnabled,
64
+ initialScrollViewScrollEnabled: typeof initialScrollViewScrollEnabled === 'undefined' ? true : initialScrollViewScrollEnabled,
65
+ nestedScrollable: scrollable
49
66
  });
67
+ const combinedGesture = useMemo(() => {
68
+ // android is able to handle nested scroll view, but not the full height ones like iOS
69
+ if (outerScrollGesture && !(Platform.OS === 'android' && scrollable)) {
70
+ return Gesture.Simultaneous(outerScrollGesture, gestureHandler);
71
+ }
72
+ return gestureHandler;
73
+ }, [scrollable, outerScrollGesture, gestureHandler]);
50
74
  const renderAnimatedCell = useCallback(({
51
75
  cellKey,
52
76
  ...props
@@ -63,7 +87,7 @@ const ReorderableList = ({
63
87
  return /*#__PURE__*/React.createElement(ReorderableListContext.Provider, {
64
88
  value: listContextValue
65
89
  }, /*#__PURE__*/React.createElement(GestureDetector, {
66
- gesture: gestureHandler
90
+ gesture: combinedGesture
67
91
  }, /*#__PURE__*/React.createElement(AnimatedFlatList, _extends({}, rest, {
68
92
  ref: handleRef,
69
93
  data: data,
@@ -75,9 +99,10 @@ const ReorderableList = ({
75
99
  removeClippedSubviews: false,
76
100
  keyExtractor: keyExtractor,
77
101
  extraData: extraData,
78
- numColumns: 1
102
+ numColumns: 1,
103
+ scrollEnabled: scrollEnabled
79
104
  }))));
80
105
  };
81
- const MemoizedReorderableList = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(ReorderableList));
82
- export { MemoizedReorderableList as ReorderableList };
83
- //# sourceMappingURL=ReorderableList.js.map
106
+ const MemoizedReorderableListCore = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(ReorderableListCore));
107
+ export { MemoizedReorderableListCore as ReorderableListCore };
108
+ //# sourceMappingURL=ReorderableListCore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useMemo","FlatList","Platform","Gesture","GestureDetector","Animated","AUTOSCROLL_CONFIG","useReorderableListCore","ReorderableListContext","ReorderableListCell","AnimatedFlatList","createAnimatedComponent","ReorderableListCore","data","autoscrollThreshold","autoscrollSpeedScale","autoscrollDelay","delay","animationDuration","dragReorderThreshold","onLayout","onReorder","onScroll","onDragEnd","keyExtractor","extraData","scrollViewContainerRef","scrollViewHeightY","scrollViewScrollOffsetY","scrollViewScrollEnabled","scrollEnabled","initialScrollViewScrollEnabled","scrollable","outerScrollGesture","rest","ref","gestureHandler","handleScroll","handleFlatListLayout","handleRef","startDrag","listContextValue","itemOffset","itemHeight","dragY","draggedIndex","duration","initialScrollEnabled","nestedScrollable","combinedGesture","OS","Simultaneous","renderAnimatedCell","cellKey","props","createElement","_extends","key","index","Provider","value","gesture","CellRendererComponent","scrollEventThrottle","horizontal","removeClippedSubviews","numColumns","MemoizedReorderableListCore","memo","forwardRef"],"sourceRoot":"../../../../src","sources":["components/ReorderableListCore/ReorderableListCore.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAGC,WAAW,EAAEC,OAAO,QAAO,OAAO;AACjD,SAEEC,QAAQ,EAERC,QAAQ,QAEH,cAAc;AAErB,SACEC,OAAO,EACPC,eAAe,QAEV,8BAA8B;AACrC,OAAOC,QAAQ,MAAqB,yBAAyB;AAE7D,SAAQC,iBAAiB,QAAO,aAAa;AAC7C,SAAQC,sBAAsB,QAAO,0BAA0B;AAC/D,SAAQC,sBAAsB,QAAO,gBAAgB;AAErD,SAAQC,mBAAmB,QAAO,wBAAwB;AAE1D,MAAMC,gBAAgB,GAAGL,QAAQ,CAACM,uBAAuB,CACvDV,QACF,CAEuB;AAcvB,MAAMW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B,gBAAGrE,KAAK,CAACsE,IAAI,cAC5CtE,KAAK,CAACuE,UAAU,CAACzD,mBAAmB,CACtC,CAIuB;AAEvB,SAAQuD,2BAA2B,IAAIvD,mBAAmB","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import { Platform } from 'react-native';
2
+ const IOS_CONFIG = {
3
+ delay: 80,
4
+ increment: 100
5
+ };
6
+ const ANDROID_FABRIC_CONFIG = {
7
+ delay: 50,
8
+ increment: 80
9
+ };
10
+ const ANDROID_PAPER_CONFIG = {
11
+ delay: 10,
12
+ increment: 4
13
+ };
14
+ export const IS_FABRIC = global && typeof global === 'object' && 'nativeFabricUIManager' in global;
15
+ export const AUTOSCROLL_CONFIG = Platform.select({
16
+ // autoscroll behaves differently with Fabric and Paper on Android
17
+ android: IS_FABRIC ? ANDROID_FABRIC_CONFIG : ANDROID_PAPER_CONFIG,
18
+ ios: IOS_CONFIG,
19
+ // unsupported platforms
20
+ web: IOS_CONFIG,
21
+ macos: IOS_CONFIG,
22
+ windows: IOS_CONFIG,
23
+ native: IOS_CONFIG
24
+ });
25
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","IOS_CONFIG","delay","increment","ANDROID_FABRIC_CONFIG","ANDROID_PAPER_CONFIG","IS_FABRIC","global","AUTOSCROLL_CONFIG","select","android","ios","web","macos","windows","native"],"sourceRoot":"../../../../src","sources":["components/ReorderableListCore/constants.ts"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,cAAc;AAErC,MAAMC,UAAU,GAAG;EACjBC,KAAK,EAAE,EAAE;EACTC,SAAS,EAAE;AACb,CAAC;AAED,MAAMC,qBAAqB,GAAG;EAC5BF,KAAK,EAAE,EAAE;EACTC,SAAS,EAAE;AACb,CAAC;AAED,MAAME,oBAAoB,GAAG;EAC3BH,KAAK,EAAE,EAAE;EACTC,SAAS,EAAE;AACb,CAAC;AAED,OAAO,MAAMG,SAAS,GACpBC,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,uBAAuB,IAAIA,MAAM;AAE3E,OAAO,MAAMC,iBAAiB,GAAGR,QAAQ,CAACS,MAAM,CAAC;EAC/C;EACAC,OAAO,EAAEJ,SAAS,GAAGF,qBAAqB,GAAGC,oBAAoB;EACjEM,GAAG,EAAEV,UAAU;EAEf;EACAW,GAAG,EAAEX,UAAU;EACfY,KAAK,EAAEZ,UAAU;EACjBa,OAAO,EAAEb,UAAU;EACnBc,MAAM,EAAEd;AACV,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from './ReorderableListCore';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/ReorderableListCore/index.ts"],"mappings":"AAAA,cAAc,uBAAuB","ignoreList":[]}
@@ -1,12 +1,12 @@
1
- import React, { useCallback, useMemo } from 'react';
1
+ import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import { unstable_batchedUpdates } from 'react-native';
3
3
  import { Gesture, State } from 'react-native-gesture-handler';
4
- import { Easing, cancelAnimation, measure, runOnJS, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
5
- import { AUTOSCROLL_INCREMENT } from './constants';
4
+ import { Easing, runOnJS, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
5
+ import { AUTOSCROLL_CONFIG } from './constants';
6
6
  import { ReorderableListState } from '../../types';
7
7
  const version = React.version.split('.');
8
8
  const hasAutomaticBatching = version.length ? parseInt(version[0], 10) >= 18 : false;
9
- export const useReorderableList = ({
9
+ export const useReorderableListCore = ({
10
10
  ref,
11
11
  autoscrollThreshold,
12
12
  autoscrollSpeedScale,
@@ -16,22 +16,30 @@ export const useReorderableList = ({
16
16
  onReorder,
17
17
  onDragEnd,
18
18
  onScroll,
19
- onLayout
19
+ onLayout,
20
+ scrollViewContainerRef,
21
+ scrollViewHeightY,
22
+ scrollViewScrollOffsetY,
23
+ scrollViewScrollEnabled,
24
+ initialScrollEnabled,
25
+ initialScrollViewScrollEnabled,
26
+ nestedScrollable
20
27
  }) => {
21
- const scrollEnabled = useSharedValue(true);
22
- const flatList = useAnimatedRef();
28
+ const flatListRef = useAnimatedRef();
29
+ const scrollEnabled = useSharedValue(initialScrollEnabled);
23
30
  const gestureState = useSharedValue(State.UNDETERMINED);
24
31
  const currentY = useSharedValue(0);
25
32
  const currentTranslationY = useSharedValue(0);
26
- const containerPositionY = useSharedValue(0);
27
- const currentScrollOffsetY = useSharedValue(0);
33
+ const flatListScrollOffsetY = useSharedValue(0);
34
+ const flatListHeightY = useSharedValue(0);
35
+ const nestedFlatListPositionY = useSharedValue(0);
28
36
  const dragScrollTranslationY = useSharedValue(0);
29
37
  const dragInitialScrollOffsetY = useSharedValue(0);
38
+ const scrollViewDragScrollTranslationY = useSharedValue(0);
39
+ const scrollViewDragInitialScrollOffsetY = useSharedValue(0);
30
40
  const draggedHeight = useSharedValue(0);
31
41
  const itemOffset = useSharedValue([]);
32
42
  const itemHeight = useSharedValue([]);
33
- const topAutoscrollArea = useSharedValue(0);
34
- const bottomAutoscrollArea = useSharedValue(0);
35
43
  const autoscrollTrigger = useSharedValue(-1);
36
44
  const lastAutoscrollTrigger = useSharedValue(-1);
37
45
  const previousY = useSharedValue(0);
@@ -42,25 +50,22 @@ export const useReorderableList = ({
42
50
  const draggedIndex = useSharedValue(-1);
43
51
  const state = useSharedValue(ReorderableListState.IDLE);
44
52
  const dragEndHandlers = useSharedValue([]);
45
-
46
- // animation duration as a shared value allows to avoid re-rendering of all cells on value change
53
+ const startY = useSharedValue(0);
47
54
  const duration = useSharedValue(animationDuration);
48
- if (duration.value !== animationDuration) {
55
+ useEffect(() => {
49
56
  duration.value = animationDuration;
50
- }
57
+ }, [duration, animationDuration]);
51
58
  const listContextValue = useMemo(() => ({
52
59
  draggedHeight,
53
60
  currentIndex,
54
61
  draggedIndex,
55
62
  dragEndHandlers
56
63
  }), [draggedHeight, currentIndex, draggedIndex, dragEndHandlers]);
57
- const startY = useSharedValue(0);
58
64
  const panGestureHandler = useMemo(() => Gesture.Pan().onBegin(e => {
59
65
  // prevent new dragging until item is completely released
60
66
  if (state.value === ReorderableListState.IDLE) {
61
- const relativeY = e.absoluteY - containerPositionY.value;
62
- startY.value = relativeY;
63
- currentY.value = relativeY;
67
+ startY.value = e.y;
68
+ currentY.value = e.y;
64
69
  currentTranslationY.value = e.translationY;
65
70
  if (draggedIndex.value >= 0) {
66
71
  dragY.value = e.translationY;
@@ -72,29 +77,40 @@ export const useReorderableList = ({
72
77
  currentY.value = startY.value + e.translationY;
73
78
  currentTranslationY.value = e.translationY;
74
79
  if (draggedIndex.value >= 0) {
75
- dragY.value = e.translationY + dragScrollTranslationY.value;
80
+ dragY.value = e.translationY + dragScrollTranslationY.value + scrollViewDragScrollTranslationY.value;
76
81
  }
77
82
  gestureState.value = e.state;
78
83
  }
79
- }).onEnd(e => gestureState.value = e.state).onFinalize(e => gestureState.value = e.state), [containerPositionY, currentTranslationY, currentY, dragScrollTranslationY, draggedIndex, gestureState, dragY, startY, state]);
84
+ }).onEnd(e => gestureState.value = e.state).onFinalize(e => gestureState.value = e.state), [currentTranslationY, currentY, dragScrollTranslationY, scrollViewDragScrollTranslationY, draggedIndex, gestureState, dragY, startY, state]);
80
85
  const gestureHandler = useMemo(() => Gesture.Simultaneous(Gesture.Native(), panGestureHandler), [panGestureHandler]);
81
86
  const setScrollEnabled = useCallback(enabled => {
82
- var _flatList$current;
83
- scrollEnabled.value = enabled;
84
- (_flatList$current = flatList.current) === null || _flatList$current === void 0 || _flatList$current.setNativeProps({
85
- scrollEnabled: enabled
86
- });
87
- }, [flatList, scrollEnabled]);
87
+ // if scroll is enabled on list props then we can toggle it
88
+ if (initialScrollEnabled) {
89
+ var _flatListRef$current;
90
+ scrollEnabled.value = enabled;
91
+ (_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 || _flatListRef$current.setNativeProps({
92
+ scrollEnabled: enabled
93
+ });
94
+ }
95
+ if (scrollViewContainerRef && scrollViewScrollEnabled && initialScrollViewScrollEnabled) {
96
+ var _scrollViewContainerR;
97
+ scrollViewScrollEnabled.value = enabled;
98
+ (_scrollViewContainerR = scrollViewContainerRef.current) === null || _scrollViewContainerR === void 0 || _scrollViewContainerR.setNativeProps({
99
+ scrollEnabled: enabled
100
+ });
101
+ }
102
+ }, [initialScrollEnabled, flatListRef, scrollEnabled, initialScrollViewScrollEnabled, scrollViewContainerRef, scrollViewScrollEnabled]);
88
103
  const resetSharedValues = useCallback(() => {
89
104
  'worklet';
90
105
 
91
- draggedIndex.value = -1;
92
106
  // current index is reset on item render for the on end event
93
- dragY.value = 0;
107
+ draggedIndex.value = -1;
94
108
  // released flag is reset after release is triggered in the item
95
109
  state.value = ReorderableListState.IDLE;
110
+ dragY.value = 0;
96
111
  dragScrollTranslationY.value = 0;
97
- }, [draggedIndex, dragY, state, dragScrollTranslationY]);
112
+ scrollViewDragScrollTranslationY.value = 0;
113
+ }, [dragY, dragScrollTranslationY, scrollViewDragScrollTranslationY, draggedIndex, state]);
98
114
  const reorder = (fromIndex, toIndex) => {
99
115
  runOnUI(resetSharedValues)();
100
116
  if (fromIndex !== toIndex) {
@@ -114,7 +130,7 @@ export const useReorderableList = ({
114
130
  const getIndexFromY = useCallback(y => {
115
131
  'worklet';
116
132
 
117
- const relativeY = currentScrollOffsetY.value + y;
133
+ const relativeY = flatListScrollOffsetY.value + y;
118
134
  const count = itemOffset.value.length;
119
135
  for (let i = 0; i < count; i++) {
120
136
  if (currentIndex.value === i) {
@@ -135,7 +151,7 @@ export const useReorderableList = ({
135
151
  index: currentIndex.value,
136
152
  direction: previousDirection.value
137
153
  };
138
- }, [dragReorderThreshold, currentIndex, currentScrollOffsetY, previousDirection, itemOffset, itemHeight]);
154
+ }, [dragReorderThreshold, currentIndex, flatListScrollOffsetY, previousDirection, itemOffset, itemHeight]);
139
155
  const setCurrentIndex = useCallback(y => {
140
156
  'worklet';
141
157
 
@@ -203,52 +219,154 @@ export const useReorderableList = ({
203
219
  }
204
220
  }
205
221
  });
206
- useAnimatedReaction(() => currentY.value, y => {
222
+ const calculateHiddenArea = useCallback(() => {
223
+ 'worklet';
224
+
225
+ if (!scrollViewScrollOffsetY || !scrollViewHeightY) {
226
+ return {
227
+ top: 0,
228
+ bottom: 0
229
+ };
230
+ }
231
+
232
+ // hidden area cannot be negative
233
+ const top = Math.max(0, scrollViewScrollOffsetY.value - nestedFlatListPositionY.value);
234
+ const bottom = Math.max(0, nestedFlatListPositionY.value + flatListHeightY.value - (scrollViewScrollOffsetY.value + scrollViewHeightY.value));
235
+ return {
236
+ top,
237
+ bottom
238
+ };
239
+ }, [scrollViewScrollOffsetY, scrollViewHeightY, nestedFlatListPositionY, flatListHeightY]);
240
+ const calculateThresholdArea = useCallback(hiddenArea => {
241
+ 'worklet';
242
+
243
+ const threshold = Math.max(0, Math.min(autoscrollThreshold, 0.4));
244
+ const visibleHeight = flatListHeightY.value - (hiddenArea.top + hiddenArea.bottom);
245
+ const top = visibleHeight * threshold;
246
+ const bottom = flatListHeightY.value - top;
247
+ return {
248
+ top,
249
+ bottom
250
+ };
251
+ }, [autoscrollThreshold, flatListHeightY]);
252
+ const calculateThresholdAreaParent = useCallback(hiddenArea => {
253
+ 'worklet';
254
+
255
+ const threshold = Math.max(0, Math.min(autoscrollThreshold, 0.4));
256
+ const top = flatListHeightY.value * threshold;
257
+ const bottom = flatListHeightY.value - top;
258
+
259
+ // if the hidden area is 0 then we don't have a threshold area
260
+ // we might have floating errors like 0.0001 which we should ignore
261
+ return {
262
+ top: hiddenArea.top > 0.1 ? top + hiddenArea.top : 0,
263
+ bottom: hiddenArea.bottom > 0.1 ? bottom - hiddenArea.bottom : 0
264
+ };
265
+ }, [autoscrollThreshold, flatListHeightY]);
266
+ const shouldScrollParent = useCallback(y => {
267
+ 'worklet';
268
+
269
+ const hiddenArea = calculateHiddenArea();
270
+ const thresholdAreaParent = calculateThresholdAreaParent(hiddenArea);
271
+
272
+ // we might have floating errors like 0.0001 which we should ignore
273
+ return hiddenArea.top > 0.1 && y <= thresholdAreaParent.top || hiddenArea.bottom > 0.1 && y >= thresholdAreaParent.bottom;
274
+ }, [calculateHiddenArea, calculateThresholdAreaParent]);
275
+ const scrollDirection = useCallback(y => {
276
+ 'worklet';
277
+
278
+ const hiddenArea = calculateHiddenArea();
279
+ if (shouldScrollParent(y)) {
280
+ const thresholdAreaParent = calculateThresholdAreaParent(hiddenArea);
281
+ if (y <= thresholdAreaParent.top) {
282
+ return -1;
283
+ }
284
+ if (y >= thresholdAreaParent.bottom) {
285
+ return 1;
286
+ }
287
+ return 0;
288
+ } else if (nestedScrollable) {
289
+ const thresholdArea = calculateThresholdArea(hiddenArea);
290
+ if (y <= thresholdArea.top) {
291
+ return -1;
292
+ }
293
+ if (y >= thresholdArea.bottom) {
294
+ return 1;
295
+ }
296
+ }
297
+ return 0;
298
+ }, [nestedScrollable, shouldScrollParent, calculateHiddenArea, calculateThresholdArea, calculateThresholdAreaParent]);
299
+ useAnimatedReaction(() => currentY.value + scrollViewDragScrollTranslationY.value, y => {
207
300
  if (state.value === ReorderableListState.DRAGGING || state.value === ReorderableListState.AUTO_SCROLL) {
208
301
  setCurrentIndex(y);
209
- if (y <= topAutoscrollArea.value || y >= bottomAutoscrollArea.value) {
302
+ if (scrollDirection(y) !== 0) {
210
303
  if (state.value !== ReorderableListState.AUTO_SCROLL) {
211
304
  // trigger autoscroll
212
305
  lastAutoscrollTrigger.value = autoscrollTrigger.value;
213
306
  autoscrollTrigger.value *= -1;
307
+ state.value = ReorderableListState.AUTO_SCROLL;
214
308
  }
215
- state.value = ReorderableListState.AUTO_SCROLL;
216
- } else {
309
+ } else if (state.value === ReorderableListState.AUTO_SCROLL) {
217
310
  state.value = ReorderableListState.DRAGGING;
218
311
  }
219
312
  }
220
313
  });
221
314
  useAnimatedReaction(() => autoscrollTrigger.value, () => {
222
315
  if (autoscrollTrigger.value !== lastAutoscrollTrigger.value && state.value === ReorderableListState.AUTO_SCROLL) {
223
- const autoscrollIncrement = (currentY.value <= topAutoscrollArea.value ? -AUTOSCROLL_INCREMENT : AUTOSCROLL_INCREMENT) * autoscrollSpeedScale;
316
+ let y = currentY.value + scrollViewDragScrollTranslationY.value;
317
+ const autoscrollIncrement = scrollDirection(y) * AUTOSCROLL_CONFIG.increment * autoscrollSpeedScale;
224
318
  if (autoscrollIncrement !== 0) {
225
- scrollTo(flatList, 0, currentScrollOffsetY.value + autoscrollIncrement, true);
319
+ let scrollOffset = flatListScrollOffsetY.value;
320
+ let listRef = flatListRef;
321
+ if (shouldScrollParent(y) && scrollViewScrollOffsetY) {
322
+ scrollOffset = scrollViewScrollOffsetY.value;
323
+ listRef = scrollViewContainerRef;
324
+ }
325
+ scrollTo(listRef, 0, scrollOffset + autoscrollIncrement, true);
226
326
  }
227
327
 
228
328
  // when autoscrolling user may not be moving his finger so we need
229
329
  // to update the current position of the dragged item here
230
- setCurrentIndex(currentY.value);
330
+ setCurrentIndex(y);
231
331
  }
232
332
  });
333
+
334
+ // flatlist scroll handler
233
335
  const handleScroll = useAnimatedScrollHandler(e => {
234
- currentScrollOffsetY.value = e.contentOffset.y;
336
+ flatListScrollOffsetY.value = e.contentOffset.y;
235
337
 
236
338
  // checking if the list is not scrollable instead of the scrolling state
237
339
  // fixes a bug on iOS where the item is shifted after autoscrolling and then
238
- // moving await from autoscroll area
340
+ // moving away from autoscroll area
239
341
  if (!scrollEnabled.value) {
240
- dragScrollTranslationY.value = currentScrollOffsetY.value - dragInitialScrollOffsetY.value;
342
+ dragScrollTranslationY.value = flatListScrollOffsetY.value - dragInitialScrollOffsetY.value;
241
343
  }
242
344
  if (state.value === ReorderableListState.AUTO_SCROLL) {
243
- dragY.value = currentTranslationY.value + dragScrollTranslationY.value;
244
- cancelAnimation(autoscrollTrigger);
345
+ dragY.value = currentTranslationY.value + dragScrollTranslationY.value + scrollViewDragScrollTranslationY.value;
245
346
  lastAutoscrollTrigger.value = autoscrollTrigger.value;
246
347
  autoscrollTrigger.value = withDelay(autoscrollDelay, withTiming(autoscrollTrigger.value * -1, {
247
348
  duration: 0
248
349
  }));
249
- } else {}
250
- if (onScroll) {
251
- onScroll(e);
350
+ }
351
+ onScroll === null || onScroll === void 0 || onScroll(e);
352
+ });
353
+
354
+ // parent scroll handler
355
+ useAnimatedReaction(() => scrollViewScrollOffsetY === null || scrollViewScrollOffsetY === void 0 ? void 0 : scrollViewScrollOffsetY.value, value => {
356
+ if (value && scrollViewScrollEnabled) {
357
+ // checking if the list is not scrollable instead of the scrolling state
358
+ // fixes a bug on iOS where the item is shifted after autoscrolling and then
359
+ // moving await from autoscroll area
360
+ if (!scrollViewScrollEnabled.value) {
361
+ scrollViewDragScrollTranslationY.value = value - scrollViewDragInitialScrollOffsetY.value;
362
+ }
363
+ if (state.value === ReorderableListState.AUTO_SCROLL) {
364
+ dragY.value = currentTranslationY.value + scrollViewDragScrollTranslationY.value;
365
+ lastAutoscrollTrigger.value = autoscrollTrigger.value;
366
+ autoscrollTrigger.value = withDelay(autoscrollDelay, withTiming(autoscrollTrigger.value * -1, {
367
+ duration: 0
368
+ }));
369
+ }
252
370
  }
253
371
  });
254
372
  const startDrag = useCallback(index => {
@@ -256,38 +374,26 @@ export const useReorderableList = ({
256
374
 
257
375
  // allow new drag when item is completely released
258
376
  if (state.value === ReorderableListState.IDLE) {
377
+ // resetting shared values again fixes a flickeing bug in nested lists where
378
+ // after scrolling the parent list it would offset the new dragged item in another nested list
379
+ resetSharedValues();
380
+ dragInitialScrollOffsetY.value = flatListScrollOffsetY.value;
381
+ scrollViewDragInitialScrollOffsetY.value = scrollViewScrollOffsetY ? scrollViewScrollOffsetY.value : 0;
259
382
  draggedHeight.value = itemHeight.value[index];
260
383
  draggedIndex.value = index;
261
384
  previousIndex.value = -1;
262
385
  currentIndex.value = index;
263
386
  state.value = ReorderableListState.DRAGGING;
264
- dragInitialScrollOffsetY.value = currentScrollOffsetY.value;
265
387
  runOnJS(setScrollEnabled)(false);
266
388
  }
267
- }, [setScrollEnabled, currentIndex, previousIndex, draggedHeight, draggedIndex, state, currentScrollOffsetY, dragInitialScrollOffsetY, itemHeight]);
268
- const measureFlatList = useCallback(() => {
269
- 'worklet';
270
-
271
- const measurement = measure(flatList);
272
- if (measurement === null) {
273
- return;
274
- }
275
- containerPositionY.value = measurement.pageY;
276
- }, [flatList, containerPositionY]);
389
+ }, [resetSharedValues, dragInitialScrollOffsetY, scrollViewScrollOffsetY, scrollViewDragInitialScrollOffsetY, setScrollEnabled, currentIndex, previousIndex, draggedHeight, draggedIndex, state, flatListScrollOffsetY, itemHeight]);
277
390
  const handleFlatListLayout = useCallback(e => {
278
- runOnUI(measureFlatList)();
279
- const threshold = Math.max(0, Math.min(autoscrollThreshold, 0.4));
280
- const {
281
- height
282
- } = e.nativeEvent.layout;
283
- topAutoscrollArea.value = height * threshold;
284
- bottomAutoscrollArea.value = height * (1 - threshold);
285
- if (onLayout) {
286
- onLayout(e);
287
- }
288
- }, [measureFlatList, topAutoscrollArea, bottomAutoscrollArea, autoscrollThreshold, onLayout]);
391
+ nestedFlatListPositionY.value = e.nativeEvent.layout.y;
392
+ flatListHeightY.value = e.nativeEvent.layout.height;
393
+ onLayout === null || onLayout === void 0 || onLayout(e);
394
+ }, [nestedFlatListPositionY, flatListHeightY, onLayout]);
289
395
  const handleRef = value => {
290
- flatList(value);
396
+ flatListRef(value);
291
397
  if (typeof ref === 'function') {
292
398
  ref(value);
293
399
  } else if (ref) {
@@ -308,4 +414,4 @@ export const useReorderableList = ({
308
414
  duration
309
415
  };
310
416
  };
311
- //# sourceMappingURL=useReorderableList.js.map
417
+ //# sourceMappingURL=useReorderableListCore.js.map