fivecar / react-native-draglist

FlatList that can be reordered by dragging its items
MIT License
119 stars 19 forks source link

Fix position of item being dragged #42

Closed MarkHaakman closed 4 months ago

MarkHaakman commented 5 months ago

This implements the suggested change in #38 . It fixes the measure parameters. An already existing example of the correct parameters can be seen in the const onDragLayout.

MarkHaakman commented 4 months ago

As long as this fix is not merged and released, you can apply the following patch with patch-package, by creating a file patches\react-native-draglist+3.6.0.patch with the following content:

diff --git a/node_modules/react-native-draglist/dist/index.js b/node_modules/react-native-draglist/dist/index.js
index 65258ef..d53e93e 100644
--- a/node_modules/react-native-draglist/dist/index.js
+++ b/node_modules/react-native-draglist/dist/index.js
@@ -143,7 +143,7 @@ function DragListImpl(props, _ref) {
         pan.setValue(gestate.dy);
       }
       panGrantedRef.current = true;
-      (_flatWrapRef$current = flatWrapRef.current) === null || _flatWrapRef$current === void 0 ? void 0 : _flatWrapRef$current.measure(function (pageX, pageY) {
+      (_flatWrapRef$current = flatWrapRef.current) === null || _flatWrapRef$current === void 0 ? void 0 : _flatWrapRef$current.measure(function (_x, _y, _width, _height, pageX, pageY) {
         flatWrapLayout.current = _extends({}, flatWrapLayout.current, {
           pos: props.horizontal ? pageX : pageY
         });
diff --git a/node_modules/react-native-draglist/dist/index.modern.js b/node_modules/react-native-draglist/dist/index.modern.js
index 0d2753b..1d7638b 100644
--- a/node_modules/react-native-draglist/dist/index.modern.js
+++ b/node_modules/react-native-draglist/dist/index.modern.js
@@ -140,7 +140,7 @@ function DragListImpl(props, _ref) {
         pan.setValue(gestate.dy);
       }
       panGrantedRef.current = true;
-      (_flatWrapRef$current = flatWrapRef.current) === null || _flatWrapRef$current === void 0 ? void 0 : _flatWrapRef$current.measure(function (pageX, pageY) {
+      (_flatWrapRef$current = flatWrapRef.current) === null || _flatWrapRef$current === void 0 ? void 0 : _flatWrapRef$current.measure(function (_x, _y, _width, _height, pageX, pageY) {
         flatWrapLayout.current = _extends({}, flatWrapLayout.current, {
           pos: props.horizontal ? pageX : pageY
         });
mphill commented 4 months ago

@fivecar, can you approve this?