FloatSpringSpec

class FloatSpringSpec(val dampingRatio: Float = Spring.DampingRatioNoBouncy, val stiffness: Float = Spring.StiffnessMedium, visibilityThreshold: Float = Spring.DefaultDisplacementThreshold) : FloatAnimationSpec

FloatSpringSpec animation uses a spring animation to animate a Float value. Its configuration can be tuned via adjusting the spring parameters, namely damping ratio and stiffness.

Parameters

dampingRatio

damping ratio of the spring. Defaults to com.jakewharton.mosaic.animation.Spring.DampingRatioNoBouncy

stiffness

Stiffness of the spring. Defaults to com.jakewharton.mosaic.animation.Spring.StiffnessMedium

visibilityThreshold

The value threshold such that the animation is no longer significant. e.g. 1px for translation animations. Defaults to com.jakewharton.mosaic.animation.Spring.DefaultDisplacementThreshold

Constructors

Link copied to clipboard
constructor(dampingRatio: Float = Spring.DampingRatioNoBouncy, stiffness: Float = Spring.StiffnessMedium, visibilityThreshold: Float = Spring.DefaultDisplacementThreshold)

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun getDurationNanos(initialValue: Float, targetValue: Float, initialVelocity: Float): Long

Calculates the duration of an animation. For duration-based animations, this will return the pre-defined duration. For physics-based animations, the duration will be estimated based on the physics configuration (such as spring stiffness, damping ratio, visibility threshold) as well as the initialValue, targetValue values, and initialVelocity.

Link copied to clipboard
open override fun getEndVelocity(initialValue: Float, targetValue: Float, initialVelocity: Float): Float

Calculates the end velocity of the animation with the provided start/end values, and start velocity. For duration-based animations, end velocity will be the velocity of the animation at the duration time. This is also the default assumption. However, for spring animations, the transient trailing velocity will be snapped to zero.

Link copied to clipboard
open override fun getValueFromNanos(playTimeNanos: Long, initialValue: Float, targetValue: Float, initialVelocity: Float): Float

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

Link copied to clipboard
open override fun getVelocityFromNanos(playTimeNanos: Long, initialValue: Float, targetValue: Float, initialVelocity: Float): Float

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

Link copied to clipboard

Create an com.jakewharton.mosaic.animation.VectorizedAnimationSpec that animates AnimationVector from a FloatAnimationSpec. Every dimension of the AnimationVector will be animated using the given FloatAnimationSpec.