Hi there, I'm migrating from compose 11 to 12 and ...
# compose
j
Hi there, I'm migrating from compose 11 to 12 and It is recommended to use
Animatable
instead of
AnimatedFloatModel
, I was using
fling
and as
Animatable
has no fling method I've switched to using
animteDecay
, what I need is some way to use both
decay
and
adjustTarget
as I did with
AnimatedFloatModel
how can I achieve it now?
d
That can be achieved via
calculateTargetValue
like this: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]idx/compose/animation/core/samples/AnimatableSamples.kt;l=142 That would give you the naturally stopping point based on decay, and you can make decisions to decay or animate to an alternative target based on that stopping point. It's essentially
adjustTarget
, expressed in a slightly different way. 🙂
🙏🏼 1
haha was just about to say
calculateTargetValue
too 🙂
😃 1
👍 1
btw the
FlingGame
sample is really coool 😄
d
😄 Thanks! I was having fun playing with the API. Hopefully it'll benefit an actual use case.
1
t
For sure. Weird coincidence, I was just thinking of making something like that the other day to try out the alpha12 APIs, and then was so glad to see it in the samples! 🙈
🎉 1
d
I'm so glad to hear that!
😄 1