Dominaezzz
07/23/2021, 7:48 AMAnimatable
or updateTransition
, during the same composition? When I update the state or call snapTo
, the update happens in the next frame or so.Doris Liu
07/23/2021, 4:21 PMDominaezzz
07/23/2021, 4:38 PMLazyColumn
drag and drop, and I want the items in the list to animate into their new positions.
To do this, when an item moves to the next/previous position, I use graphicsLayer(translationY = ....)
to draw the item in the previous position, then I animate the item into it's new position.
When I detect the change in position, I want to snap the translation to the old position immediately. Right now, the item would be rendered in the new position first, then snap to the old position, then animate back to the new position.Dominaezzz
07/23/2021, 4:40 PMDoris Liu
07/23/2021, 5:14 PMAnimatable
when you need to snap (in the current composition pass):
var translation by remember { mutableStateOf(Animatable(...)) }
and mutate that translation as needed. The LaunchedEffect
that triggers animations for Animatable
would now need to have translation
added to the keys.Dominaezzz
07/23/2021, 5:21 PMDominaezzz
07/23/2021, 5:25 PMmutableStateOf
necessary? Could I just do val translation by remember(changed) { Animatable(...) }
?Doris Liu
07/23/2021, 5:26 PMDoris Liu
07/23/2021, 5:27 PMAlso, is theYes, you could do that.necessary? Could I just domutableStateOf
?val translation by remember(changed) { Animatable(...) }
mutableStateOf
would be necessary if you need to mutate translation in a coroutine. 🙂Dominaezzz
07/23/2021, 5:29 PMDominaezzz
07/23/2021, 5:32 PMLazyColumn
not having drag and drop (or the necessary primitives I guess), so it may not be worth considering just yet. Depends on what the LazyColumn
devs think I guess.