https://kotlinlang.org logo
#compose
Title
# compose
s

ste

06/09/2022, 1:18 PM
Is there a way to pin a
LazyList
item so it doesn't get removed when it goes out of bounds? This would allow scrolling when reordering the items in a list (at least looking at my implementation). I see there are
PinnableParent
,
PinnableParent.PinnedItemsHandle
,
lazyListPinningModifier
,
ModifierLocalPinnableParent
and so on, but I couldn't find any example.
👀 1
a

Andrey Kulikov

06/09/2022, 3:00 PM
could you please explain your use case in a bit more details?
s

ste

06/09/2022, 3:29 PM
Imagine to drag a
LazyColumn
item downwards. When that item reaches the list bounds, the
LazyColumn
should scroll to keep the drag alive. However, if we keep dragging (and scrolling) downwards, the
LazyList
will dispose that item because it thinks it's not visible anymore. So, I was wondering if there was a way to tell the
LazyColumn
to not dispose that item while it is being dragged.
a

Andrey Kulikov

06/09/2022, 3:51 PM
no, there is no such api, unfortunately. for example in our demo for dragndrop the items are being reordered everytime they are moved over the center of the next item so the issue you described is not happening https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ndroidx/compose/foundation/demos/LazyColumnDragAndDropDemo.kt
s

ste

06/09/2022, 4:01 PM
Yep, keeping the source updated is a solution. I also tried that snipped before, but unfortunately it doesn't play well with my use case (e.g. when items don't have a key), so I ended up creating my own logic, which, unfortunately, can't handle list scrolling
a

Andrey Kulikov

06/09/2022, 4:28 PM
yes, but we are not planning to make this param public unfortunately, you will have to fork LazyColumn
😭 2
32 Views