Dragged item snaps back if the list is modified while it's dragged and the item would move out of the composition.
- Make two lists: [1, 2, 3, 10], and [1,2,3,4,5,6,7,8,9,10], and be sure to assign keys. Note: no more than 5 items should be on screen at the same time in that case, such that you have to scroll more than 3 items to reach the end.
- Grab item 10 from the first list, like this: [1, 2, 3, <10>]
- In response to
isAnyItemDragged, recompose the LazyColumn with the second list: [1,2,3,4,5,6,7,8,9,<10>] - For one-two frames, the item 10 ends up out of the LazyColumn's visible item list.
- The dragged item goes out of the composition, the dragged state resets for the item, the item snaps back to its original position,
isAnyItemDraggedbecomes false, and the list snaps back to [1,2,3,10] (no item dragged now).
To solve this, we need to persist the dragged item under the finger and its drag state, even if it would go out of composition when it became dragged (because the item was under the finger the whole time, it should stay on screen).
My use-case is that I want to reorder a list of items, where some items are hidden until I start reordering. For a brief moment during the gesture, the items must appear as soon as I start a drag, and disappear when I finish it.
any idea how to persist a composition even after the item scrolls off screen? it's been a problem from the beginning and the source of a lot of issues and headaches.
the main thought is that I don't want to call a composition twice such that any side effects inside will be called twice.
The only way I know is movableContentOf which essentially is a remembered composition.
amazing. thank you for all the issues btw!
Well thank you for the library Calvin! This is the only maintained library that works relatively well for reordering items! Our app heavily relies on it.
I also want to say thank for the library, it is pretty amazing and I would also like to upvote this issue, because I have been struggling with this one in my app. Thanks