nuclearpasta / react-native-drax

A drag-and-drop system for React Native
MIT License
554 stars 69 forks source link

Wrong position draggable item when orientation was changed #115

Closed xdarkleonx closed 3 years ago

xdarkleonx commented 3 years ago
<DraxProvider>
   <View style={styles.container}>
        <DraxList
          data={alphaData}
          renderItemContent={({ item }) => renderItem(item)}
          onItemReorder={({ fromIndex, toIndex }) => reorderItems(fromIndex, toIndex)}
          keyExtractor={(item) => item}
        />
      </View>
  </DraxProvider>

I am using DraxList. When I change orientation (landscape/portrait), draggable item has a wrong behavior. He is jumping ups outside of screen. I think this is happens because position is recalculates wrong when orientation changes.

lafiosca commented 3 years ago

I don't know how soon I'll be able to look into this, but to gather more information first...

As per your comments in #112, this has happened for you in Android API 29 emulator? Have you experienced it in any other environments as well? And does https://github.com/nuclearpasta/react-native-drax-example have this same buggy behavior for you? Thank you.

xdarkleonx commented 3 years ago

Video demonstration. Tested on android emulator API 29 and on device - Honor 8S. In both cases there is a bug. This example works fine. React-native-drax-example I didnt test.

lafiosca commented 3 years ago

I apologize, I’m really not trying to make this difficult; but if the example code is working for you but your own code is not, I think we will need to see a minimally reproduced example of the bad behavior to be able to debug.

xdarkleonx commented 3 years ago

I was trying reproduce mistake (here code), but I could not. I can't understand why in my project draxlist work wrong.

lafiosca commented 3 years ago

Is it possible that in your actual app the DraxProvider is nested underneath something that moves it around? You can think of the provider as an invisible view rectangle that determines the canvas for dragging. As such it should be put as high up in your hierarchy as possible, preferably in a spot where it won’t be changing layout position.

xdarkleonx commented 3 years ago

Ok, thanks. It looks like this is a problem on my side, so I am closing the issue.

lafiosca commented 3 years ago

Good luck. If you learn anything illuminating or discover a bug, please feel free to share here or reopen this issue.