There is an API or an easy way to animate an `Imag...
# compose
m
There is an API or an easy way to animate an
Image
to move to a specific point ? I have an image at the top of my screen and an another image at the bottom. I want to translate the top image to the bottom. I’m starting with animation and I’m looking if there is an easy way to do that. I found the
translateY
method but how to get the dp between the top image and the bottom image ?
o
There is a modifier, onGloballyPositionned or something like that. You could remember the positions of both views and animate from there
m
Thanks, I have the position of the bottom image 🙂 Is it possible to translate an image to a position X/Y ?
t
Hmm maybe something like
Copy code
val animatedDeltaX = Animatable(0f) // animate to target deltaX
val animatedDeltaY = Animatable(0f) // animate to target deltaY

Image( 
   modifier = Modifier.graphicsLayer { 
         translateX =  animatedDeltaX.value
         translateY = animatedDeltaY.value
   }
)
m
Perfect, it works ! Thanks you!
👍🏼 1