MohamedRejeb / compose-dnd

Compose DND is a library that allows you to easily add drag and drop functionality to your Jetpack Compose or Compose Multiplatform projects.
Apache License 2.0
299 stars 7 forks source link

Scroll and drag problem #11

Open Monabr opened 2 months ago

Monabr commented 2 months ago

Hi. You have a great library here!

I found a problem with the animation of the reordering in the list and possibly an incorrect position calculation. This happens when the list is scrollable. Please watch the attached video.

You can see 2 problems:

1) When I take the first element and start to drag it down - it does not drag, but the list suddenly scrolls.

2) When I take an element from the middle of the list and drag it up - the list does not scroll up.

https://github.com/MohamedRejeb/compose-dnd/assets/30532666/5cf12ea4-0f1b-4457-a578-8577e0a62957

MohamedRejeb commented 2 months ago

Hi, Thanks for opening this issue. As I saw from your last issue, you are setting an empty draggableContent and you are not hiding the original content during drag. The library keeps the original content in the same place during drag and doesn't change it's position and you can hide it during drag if you want, it's up to the users. And the draggableContent's position is changed during drag and have a correct position and z-index. So what you need to do is to set a correct draggableContent and hide the original content during drag like this: https://github.com/MohamedRejeb/compose-dnd/blob/15c8c9582e62fba59c87dab3904c66920096547c/sample/common/src/commonMain/kotlin/ui/ListToListWithReorderScreen.kt#L214