is there a way to turn off animations for a compos...
# compose
a
is there a way to turn off animations for a compose hierarchy, for example, in paparazzi snapshots, i want the animation to complete immediately. I can set a property / composition local manually in my composables, but that doesnt seem ideal. 🤔
z
If you’re talking about setting
MotionDurationScale
to 0, then yea that’s how to do it. That’s also how the compose animation system handles a11y-disabled animations.
a
Oh thanks. I couldn’t find in source directly where it is used. Nice!
Thank you
@Zach Klippenstein (he/him) [MOD] do you have any examples of swapping it out?
it seems its tied to a specific coroutine context
z
I don’t know how paparazzi initializes compose. It might actually require support from paparazzi, which it can do whenever it’s creating the coroutine context to pass to the recomposer.
But before I assume any more, maybe @Doris Liu knows if there’s already a way to configure this for tests in general?
d
It seems to make sense to allow the
MotionDurationScale
to be adjusted for test purposes. Please feel to file a feature request for it. In the meantime, you could set the "animator duration scale" to 0 for your tests via ContentResolver or developer options. The MotionDurationScale is observing that duration scale, so you'll be indirectly changing it. See https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ondurationScale&ss=androidx%2Fplatform%2Fframeworks%2Fsupport
a
thank yiu!
498 Views