`Modifier.animateItem()` Sometimes when I use this...
# compose
z
Modifier.animateItem()
Sometimes when I use this on my items, 1-2 of them will move around during scroll despite their indexes not changing. Its usually in the form of me scrolling back up, and when item #2 comes back into view its positioned at the bottom of the list and animated up to its actual position (where Id expect it to be at to begin with). • I use contentType quite heavily, could that be the culprit? If items are "re-used"; then their positions would indeed need to be animated? • It only happens ocassionally, perhaps 1-2 times per week (daily usage).
z
Are you using keys on all your items?
Key will determine identity for things like animation, IIUC
contentType
is only used for optimizing which nodes get reused for which items, if you do that wrong the worst that should happen is composition will be a little slower.
z
Yes, keys on all of them, and there are really only two types of items (in the last place it happened anyhow). If my understanding is correct then having one contentType for each type of item here is correct usage too?
z
If my understanding is correct then having one contentType for each type of item here is correct usage too?
Yea
> Yes, keys on all of them, and there are really only two types of items (in the last place it happened anyhow). Weird, i'd file a bug. Might be an issue with the animation logic. One thing to check would be does any state inside the item follow the item correctly, even if it's in the wrong position?
z
Fwiw, I dont have any stickyHeaders in the situation where it happened today - but it seems like it happens more frequently when theyre involved. In terms of state following the item; I dont have any mutableStateOf stuff in there but just raw Text(exercise.name) and things like that are updated before the animations kicks off (I feel like this isnt what youre asking for though). I guess Ill file a bug; I have a bunch of them saved up for reporting!
But say, if items in a LazyColumn at indexes like 5 and 20 "share" contentType; wouldnt it be somehow in a galaxy far away possible for some portion of the animation stuff to leak? I mean, that would still be a bug of course; but thinking about this it seems like the most likely candidate. Unless that sounds terribly wrong, I could try ditching the contentType stuff to see if it ever pops up again.
z
I don't know how the animation stuff works – it could certainly be content type being used incorrectly internally.
👍🏽 1