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

rsktash

11/26/2021, 10:57 AM
Hi I’ve experimented with
Copy code
Modifier.animateItemPlacement()
function of lazy list. There is a bug when we add an item to the first index of a lazy list which is full and scrollable at this moment. When it is not full added item is animated but when it is full it is not animating. As a workaround I added extra item to the top of lazy list via
Copy code
item("hint") { }
a

Andrey Kulikov

11/26/2021, 10:06 PM
can you maybe explain it in a bit more details? I don’t really understand what do you mean by full, sorry. also note that the scroll position is maintained by the key, so if you add an item before the first visible item there will be no scroll or animation, we just stay on the same item
👍 1
r

rsktash

11/27/2021, 8:38 AM
So it's intended behavior
a

Andrey Kulikov

11/29/2021, 1:43 PM
seems like you saw exactly what I described, right? yes, it will work like this even without item animations
what behavior did you expect?
r

rsktash

11/29/2021, 1:46 PM
I expected the list to be scrolled if the added item position is visible one
a

Andrey Kulikov

11/29/2021, 1:49 PM
so if you currently display some item B as the first visible item and then add A before B then this will not be animated as we still stay on B and A is not in the visible area
in other cases there should be an animation
Now I’ve added extra item at the top of a lazy list
a

Andrey Kulikov

11/29/2021, 2:29 PM
everything seems to work as expected on this video. what exactly is wrong in your opinion?
r

rsktash

11/29/2021, 2:44 PM
@Andrey Kulikov everything works as I expected because I added extra item at the top of lazy list. If I remove it the animation won’t work
a

Andrey Kulikov

11/29/2021, 2:53 PM
got it. so basically you want to stay on top of the list if you were on top previously when there is a new item added as the first one, right?
r

rsktash

11/29/2021, 2:53 PM
@Andrey Kulikov yes exactly
a

Andrey Kulikov

11/29/2021, 2:54 PM
thanks, I will think how to make it simpler to configure this behavior. good that you found a simple workaround
🙏 1
6 Views