fivecar / react-native-draglist

FlatList that can be reordered by dragging its items
MIT License
113 stars 20 forks source link

Problem on dragging selected item #38

Closed moloudayat closed 2 months ago

moloudayat commented 5 months ago

Hi, I hope you are doing good! I have a problem with react-native: 0.63.4. when I added your example to my project and tried to test it, the selected item was not in the correct position. This happened on both the Android emulator and the real device.

https://github.com/fivecar/react-native-draglist/assets/33040868/f5c63096-49b5-4399-a212-0d48a3025c4c

horaczech commented 5 months ago

I have the exact same problem. Using Expo Router for navigation, looks like it offset by the exact height of top header.

unstableair commented 5 months ago

I'm also having this issue on both iOS & Android (RN 0.72.9) Looks like the problem was introduced with version 3.6.0 as regressing to 3.5.1 fixes this on both platforms. Possibly related to #32 which seems to be a 'fix' for a very similar issue.

Act-Aks commented 4 months ago

I also have this problem, and i found that making slight change on panResponder fixed it for me,

 onPanResponderGrant: (_, gestate) => {
        if (props.horizontal) {
          pan.setValue(gestate.dx);
        } else {
          pan.setValue(gestate.dy);
        }
        panGrantedRef.current = true;

        flatWrapRef.current?.measure((_x, _y, _width, _height, pageX, pageY) => {
          flatWrapLayout.current = {
            ...flatWrapLayout.current,
            pos: props.horizontal ? pageX : pageY,
          };
        });

        onDragBegin?.();
      },

The pageX and pageY are last parameters we get from measure()

mattwhetton commented 4 months ago

I'm also having this issue - is there a fix for it? I'm using 3.6.0 (downgrading to 3.5.1 fixed for me too)

Act-Aks commented 4 months ago

I'm also having this issue - is there a fix for it? I'm using 3.6.0 (downgrading to 3.5.1 fixed for me too)

 flatWrapRef.current?.measure((_x, _y, _width, _height, pageX, pageY) => {
          flatWrapLayout.current = {
            ...flatWrapLayout.current,
            pos: props.horizontal ? pageX : pageY,
          };
        });

i think this change is required in v3.6.0 in panResponder -> onPanResponderGrant ...

rohanpoudel2 commented 4 months ago

I'm also having this issue - is there a fix for it? I'm using 3.6.0 (downgrading to 3.5.1 fixed for me too)

 flatWrapRef.current?.measure((_x, _y, _width, _height, pageX, pageY) => {
          flatWrapLayout.current = {
            ...flatWrapLayout.current,
            pos: props.horizontal ? pageX : pageY,
          };
        });

i think this change is required in v3.6.0 in panResponder -> onPanResponderGrant ...

Hello can you please direct me where to make these changes 😅

Act-Aks commented 4 months ago

I'm also having this issue - is there a fix for it? I'm using 3.6.0 (downgrading to 3.5.1 fixed for me too)

 flatWrapRef.current?.measure((_x, _y, _width, _height, pageX, pageY) => {
          flatWrapLayout.current = {
            ...flatWrapLayout.current,
            pos: props.horizontal ? pageX : pageY,
          };
        });

i think this change is required in v3.6.0 in panResponder -> onPanResponderGrant ...

Hello can you please direct me where to make these changes 😅

Hi!, it should be here -> https://github.com/fivecar/react-native-draglist/blob/f124e4065ddaa830366ed0631ebaae6ac9f3e535/src/index.tsx#L138

fivecar commented 2 months ago

Thanks to @MarkHaakman for #42, which fixes this. Released as 3.6.1. Thanks, everyone!

zhen1007 commented 1 week ago

This issue is still not fixed. I have 3 DragLists nested in FlatList. It seems to work at initial position, but It doesn't work as expected after scroll.