{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

MotionDurationScale

public interface MotionDurationScale extends CoroutineContext.Element


Provides a duration scale for motion such as animations. When the duration scaleFactor is 0, the motion will end in the next frame callback. Otherwise, the duration scaleFactor will be used as a multiplier to scale the duration of the motion. The larger the scale, the longer the motion will take to finish, and therefore the slower it will be perceived.

Testing

To control the motion duration scale in tests, create an implementation of this interface and pass it to the effectContext parameter either where you call runComposeUiTest or where you create your test rule.

Summary

Nested types

public static class MotionDurationScale.Key implements CoroutineContext.Key

Public methods

default @NonNull CoroutineContext.Key<@NonNull ?>
abstract float

Defines the multiplier for the duration of the motion.

Inherited methods

From kotlin.coroutines.CoroutineContext
From kotlin.coroutines.CoroutineContext.Element
default @NonNull R
<R extends Object> fold(
    @NonNull R initial,
    @NonNull Function2<@NonNull R, @NonNull CoroutineContext.Element, @NonNull R> operation
)
default E
default @NonNull CoroutineContext

Public methods

getKey

default @NonNull CoroutineContext.Key<@NonNull ?> getKey()

getScaleFactor

abstract float getScaleFactor()

Defines the multiplier for the duration of the motion. This value should be non-negative.

A scaleFactor of 1.0f would play the motion in real time. 0f would cause motion to finish in the next frame callback. Larger scaleFactor will result in longer durations for the motion/animation (i.e. slower animation). For example, a scaleFactor of 10f would cause an animation with a duration of 100ms to finish in 1000ms.