AnimatedFloat
class AnimatedFloat : BaseAnimatedValue<Float>
This class inherits most of the functionality from BaseAnimatedValue. In addition, it tracks
velocity and supports the definition of bounds. Once bounds are defined using setBounds, the
animation will consider itself finished when it reaches the upper or lower bound, even when the
velocity is non-zero.
Summary
Public constructors
|
This class inherits most of the functionality from BaseAnimatedValue.
|
Public methods
|
Unit |
Sets up the bounds that the animation should be constrained to.
|
Unit |
Sets the current value to the target value immediately, without any animation.
|
Inherited functions
|
From class BaseAnimatedValue
Unit |
animateTo(targetValue: T)
|
Unit |
animateTo(targetValue: T, onEnd: (AnimationEndReason, T) -> Unit)
|
Unit |
animateTo(targetValue: T, anim: AnimationBuilder<T>, onEnd: (AnimationEndReason, T) -> Unit)
Sets the target value, which effectively starts an animation to change the value from value
to the target value. If there is already an animation in flight, this method will interrupt
the ongoing animation, invoke onEnd that is associated with that animation, and start
a new animation from the current value to the new target value.
|
Unit |
animateTo(targetValue: T, anim: AnimationBuilder<T>)
|
Unit |
stop()
Stops any on-going animation. No op if no animation is running. Note that this method does
not skip the animation value to its target value. Rather the animation will be stopped in its
track.
|
|
Properties
|
Float |
Velocity of the current animation.
|
Inherited properties
|
From class BaseAnimatedValue
Boolean |
isRunning
Indicates whether the animation is running.
|
T |
targetValue
The target of the current animation. This target will not be the same as the value of the
animation, until the animation finishes un-interrupted.
|
T |
value
Current value of the animation.
|
|
Public constructors
<init>
AnimatedFloat(valueHolder: ValueHolder<Float>)
This class inherits most of the functionality from BaseAnimatedValue. In addition, it tracks
velocity and supports the definition of bounds. Once bounds are defined using setBounds, the
animation will consider itself finished when it reaches the upper or lower bound, even when the
velocity is non-zero.
Parameters |
valueHolder: ValueHolder<Float> |
A value holder of Float type whose value field will be updated during
animations |
Public methods
setBounds
fun setBounds(
min: Float = Float.NEGATIVE_INFINITY,
max: Float = Float.POSITIVE_INFINITY
): Unit
Sets up the bounds that the animation should be constrained to. Note that when the animation
reaches the bounds it will stop right away, even when there is remaining velocity.
snapTo
fun snapTo(targetValue: Float): Unit
Sets the current value to the target value immediately, without any animation.
Parameters |
targetValue: Float |
The new target value to set value to. |
Properties
velocity
var velocity: Float
Velocity of the current animation.