Abdullah Musa
07/22/2024, 4:14 PMModifier.animateItemPlacement()
inside a LazyRow
and I'm wondering how I can customize the animation when swapping two items. I'd like one of the items to animate above the row and the other one below. Is there a way to make this happen? I've tried with keyframes
, but I don't know how to get the offsets of the swapping items. Thanks.Stylianos Gakis
07/22/2024, 4:20 PManimateItemPlacement()
.
With that said, I do not see something there which allows you to edit the Z index of the item animating.Abdullah Musa
07/22/2024, 4:32 PMStylianos Gakis
07/22/2024, 6:42 PMplacementSpec = keyframes {
durationMillis = X
IntOffset(..., ...) atFraction 0.0f using ArcMode.ArcBelow
IntOffset(..., ...) atFraction 0.5f using ArcMode.ArcAbove
IntOffset(..., ...) atFraction 1f
},
But there is nothing for you to be able to grab the right values to pass to the IntOffset itself.
Nor is there something you can grab in order to know which one should be doing the arc one way, and which one should go the other wayStylianos Gakis
07/22/2024, 6:49 PMplacementSpec = keyframes {
this.durationMillis
durationMillis = 800
if (index % 2 == 0) {
IntOffset(0, -400) atFraction 0.0f using ArcMode.ArcAbove
IntOffset(-200, -200) atFraction 0.5f using ArcMode.ArcBelow
IntOffset(0, 0) atFraction 1f
} else {
IntOffset(0, 400) atFraction 0.0f using ArcMode.ArcBelow
IntOffset(200, 200) atFraction 0.5f using ArcMode.ArcAbove
IntOffset(0, 0) atFraction 1f
}
},
in my hard-coded example. And it "works", only for if you're switching around the items next to each other, and only since I know that the value 400
happens to be exactly the right number since my cards are of this height.
But if you are not operating under such very specific assumptions, I do not know what you can do atm.
Perhaps worth a feature request for this?Abdullah Musa
07/22/2024, 7:11 PMStylianos Gakis
07/22/2024, 7:13 PMStylianos Gakis
07/24/2024, 11:27 AMStylianos Gakis
07/24/2024, 11:28 AMAbdullah Musa
07/29/2024, 1:03 PM