Is there a way to pin a `LazyList` item so it does...
# compose
s
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
could you please explain your use case in a bit more details?
s
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
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
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
yes, but we are not planning to make this param public unfortunately, you will have to fork LazyColumn
😭 2