Hey guys, is it possible to animate between two di...
# compose
t
Hey guys, is it possible to animate between two different composables?
c
Not sure what animation you are looking for but Crossfade or AnimatedContent may help
t
I am trying to animate this Purple Square that is inside a LazyRow to the Green Square that is parented with the Column. The bounds must change
c
I think Compose has constraintLayout which has motionlayout. Seems like it'd be easy to do there. Have you seen

https://www.youtube.com/watch?v=7yY2OocGiQU

Maybe some of those functions there could help
c
I see. Do you have a video or mockup of the final design?
In lieu of MotionLayout in Compose, you can use the transition API to animate multiple Composables on the same timeline/transition
t
Can I animate the position/bounds of one composable to another in a different Composable?
c
Hmm I don’t think you can because Composables are not static nodes or objects in a tree per se that can be referenced and moved between hierarchies. They are declared and emitted based on state. So you if you are trying to animate/move them between hierarchies, it will likely have to be animating one version in hierarchy A and animating another version in hierarchy B.
@Doris Liu please correct me if I’m wrong and/or may have more insight on this
d
If I understand the intention correctly, you would like the item to be "lifted" out of the lazy list into the main area on top, while animating the bounds? That seems like a shared element transition, which we are working on right now. We are also building a new feature (i.e. composition as a value) that would allow you to reparent a composable from one location in the tree to another, which would make this use case straightforward. 🙂 @Topaz Centuallas Would you mind sharing a video of what you are going for so I can account for this case as we build shared element transition support?
👀 1
t
@Simon Stahl can provide more information about this. But it does seem like if we can have composition as value, that can be an ideal solution. I will see if I can share a video.
👍 2
s
hi. thanks for the input so far. sounds like composition as value would be perfect for this scenario.
give me a moment. i try to hack something together for a video that i can share
@Doris Liu going to dm you the video
🙏 1