VectorizedKeyframesSpec
VectorizedKeyframesSpec class manages the animation based on the values defined at different timestamps in the duration of the animation (i.e. different keyframes). Each keyframe can be provided via keyframes parameter. VectorizedKeyframesSpec allows very specific animation definitions with a precision to millisecond.
Here's an example of creating a VectorizedKeyframesSpec animation: (keyframes and KeyframesSpec.KeyframesSpecConfig could make defining key frames much more readable.)
val delay = 120
val startValue = AnimationVector3D(100f, 200f, 300f)
val endValue = AnimationVector3D(200f, 100f, 0f)
val keyframes = VectorizedKeyframesSpec(
keyframes = mutableMapOf (
0 to (startValue to LinearEasing),
100 to (startValue to FastOutLinearInEasing)
),
durationMillis = 200,
delayMillis = delay
)
The interpolation between each value is dictated by VectorizedKeyframeSpecElementInfo.arcMode on each keyframe. If no keyframe information is provided, initialArcMode is used.
See also
Constructors
Properties
delay defines the amount of time that animation can be delayed.
duration is the amount of time while animation is not yet finished.
Whether or not the VectorizedAnimationSpec specifies an infinite animation. That is, one that will not finish by itself, one that needs an external action to stop. For examples, an indeterminate progress bar, which will only stop when it is removed from the composition.
Functions
Creates a TargetBasedAnimation from a given com.jakewharton.mosaic.animation.VectorizedAnimationSpec of AnimationVector type. This convenient method is intended for when the value being animated (i.e. start value, end value, etc) is of AnimationVector type.
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.
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 physics-based animations, end velocity is an AnimationVector of 0s.