VectorizedAnimationSpec
VectorizedAnimationSpecs are stateless vector based animation specifications. They do not assume any starting/ending conditions. Nor do they manage a lifecycle. All it stores is the configuration that is particular to the type of the animation. easing and duration for VectorizedTweenSpecs, or spring constants for VectorizedSpringSpecs. Its stateless nature allows the same VectorizedAnimationSpec to be reused by a few different running animations with different starting and ending values. More importantly, it allows the system to reuse the same animation spec when the animation target changes in-flight.
Since VectorizedAnimationSpecs are stateless, it requires starting value/velocity and ending value to be passed in, along with playtime, to calculate the value or velocity at that time. Play time here is the progress of the animation in terms of milliseconds, where 0 means the start of the animation and getDurationNanos returns the play time for the end of the animation.
Note: For use cases where the starting values/velocity and ending values aren't expected to change, it is recommended to use Animation that caches these static values and hence does not require them to be supplied in the value/velocity calculation.
See also
Inheritors
Properties
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.