Google is committed to advancing racial equity for Black communities. See how.

SpringSpec

@Immutable class SpringSpec<T> : AnimationSpec<T>
kotlin.Any
   ↳ androidx.compose.animation.core.SpringSpec

Creates a SpringSpec that uses the given spring constants (i.e. dampingRatio and stiffness. The optional visibilityThreshold defines when the animation should be considered to be visually close enough to round off to its target.

Summary

Public constructors
<init>(dampingRatio: Float = Spring.DampingRatioNoBouncy, stiffness: Float = Spring.StiffnessMedium, visibilityThreshold: T? = null)

Creates a SpringSpec that uses the given spring constants (i.

Public methods
VectorizedSpringSpec<V>
vectorize(converter: TwoWayConverter<T, V>)

Creates a VectorizedAnimationSpec with the given TwoWayConverter.

Properties
Float

damping ratio of the spring.

Float

stiffness of the spring.

T?

specifies the visibility threshold

Public constructors

<init>

SpringSpec(
    dampingRatio: Float = Spring.DampingRatioNoBouncy,
    stiffness: Float = Spring.StiffnessMedium,
    visibilityThreshold: T? = null)

Creates a SpringSpec that uses the given spring constants (i.e. dampingRatio and stiffness. The optional visibilityThreshold defines when the animation should be considered to be visually close enough to round off to its target.

Parameters
dampingRatio: Float = Spring.DampingRatioNoBouncy damping ratio of the spring. Spring.DampingRatioNoBouncy by default.
stiffness: Float = Spring.StiffnessMedium stiffness of the spring. Spring.StiffnessMedium by default.
visibilityThreshold: T? = null specifies the visibility threshold

Public methods

vectorize

fun <V : AnimationVector> vectorize(converter: TwoWayConverter<T, V>): VectorizedSpringSpec<V>

Creates a VectorizedAnimationSpec with the given TwoWayConverter.

The underlying animation system operates on AnimationVectors. T will be converted to AnimationVector to animate. VectorizedAnimationSpec describes how the converted AnimationVector should be animated. E.g. The animation could simply interpolate between the start and end values (i.e.TweenSpec), or apply spring physics to produce the motion (i.e. SpringSpec), etc)

Parameters
converter: TwoWayConverter<T, V> converts the type T from and to AnimationVector type

Properties

dampingRatio

val dampingRatio: Float

damping ratio of the spring. Spring.DampingRatioNoBouncy by default.

stiffness

val stiffness: Float

stiffness of the spring. Spring.StiffnessMedium by default.

visibilityThreshold

val visibilityThreshold: T?

specifies the visibility threshold