API Reference / @gtkx/animated / SpringValue
Class: SpringValue<T>
Only numbers, strings, and arrays of numbers/strings are supported. Non-animatable strings are also supported.
Extends
FrameValue<T>
Type Parameters
T
T = any
Constructors
Constructor
new SpringValue<
T>(from,props?):SpringValue<T>
Parameters
from
Exclude<T, object>
props?
SpringUpdate<T>
Returns
SpringValue<T>
Overrides
Constructor
new SpringValue<
T>(props?):SpringValue<T>
Parameters
props?
SpringUpdate<T>
Returns
SpringValue<T>
Overrides
FrameValue<T>.constructor
Properties
_lastCallId
protected_lastCallId:number
The counter for tracking scheduleProps calls
_lastToId
protected_lastToId:number
The last scheduleProps call that changed the to prop
_memoizedDuration
protected_memoizedDuration:number
_pendingCalls
protected_pendingCalls:Set<AnimationResolver<SpringValue<T>>>
The promise resolvers of pending start calls
_priority
protected_priority:number
Inherited from
_state
protected_state:RunAsyncState<SpringValue<T>>
The state for runAsync calls
animation
animation:
Animation<T>
The animation state
defaultProps
defaultProps:
DefaultSpringProps<T>
Some props have customizable default values
id
readonlyid:number
Inherited from
key?
optionalkey?:string
The property name used when to or from is an object. Useful when debugging too.
Overrides
queue?
optionalqueue?:SpringUpdate<T>[]
The queue of pending props
Accessors
goal
Get Signature
get goal():
T
Returns
T
hasAnimated
Get Signature
get hasAnimated():
boolean
When true, this value has been animated at least once.
Returns
boolean
idle
Get Signature
get idle():
boolean
Equals true when not advancing on each frame.
Returns
boolean
Overrides
isAnimating
Get Signature
get isAnimating():
boolean
When true, this value has an unfinished animation, which is either active or paused.
Returns
boolean
isDelayed
Get Signature
get isDelayed():
boolean|undefined
Returns
boolean | undefined
isPaused
Get Signature
get isPaused():
boolean
When true, all current and future animations are paused.
Returns
boolean
priority
Get Signature
get priority():
number
Returns
number
Set Signature
set priority(
priority):void
Parameters
priority
number
Returns
void
Inherited from
velocity
Get Signature
get velocity():
VelocityProp<T>
Returns
VelocityProp<T>
Methods
_attach()
protected_attach():void
Called when the first child is added.
Returns
void
Overrides
_detach()
protected_detach():void
Called when the last child is removed.
Returns
void
Overrides
_focus()
protected_focus(value):void
Update the animation.to value, which might be a FluidValue
Parameters
value
T | FluidValue<T, any>
Returns
void
_merge()
protected_merge(range,props,resolve):void
Merge props into the current animation
Parameters
range
AnimationRange<T>
props
RunAsyncProps<SpringValue<T>>
resolve
AnimationResolver<SpringValue<T>>
Returns
void
_onChange()
protected_onChange(value,idle?):void
Tell our children about our new value
Parameters
value
T
idle?
boolean
Returns
void
Overrides
_onPriorityChange()
protected_onPriorityChange(priority):void
Tell our children about our new priority
Parameters
priority
number
Returns
void
Inherited from
_onStart()
protected_onStart():void
Returns
void
_prepareNode()
protected_prepareNode(props):object
Parse the to and from range from the given props object.
This also ensures the initial value is available to animated components during the render phase.
Parameters
props
default?
any
from?
any
reverse?
boolean
to?
any
Returns
object
from
from:
any
to
to:
any
_resume()
protected_resume():void
Returns
void
_set()
protected_set(arg,idle?):Animated<any> |undefined
Update the current value from outside the frameloop, and return the Animated node.
Parameters
arg
T | FluidValue<T, any>
idle?
boolean
Returns
Animated<any> | undefined
_start()
protected_start():void
Returns
void
_stop()
protected_stop(goal?,cancel?):void
Exit the frameloop and notify onRest listeners.
Always wrap _stop calls with batchedUpdates.
Parameters
goal?
any
cancel?
boolean
Returns
void
_update()
protected_update(__namedParameters,isLoop?):AsyncResult<SpringValue<T>>
Every update is processed by this method before merging.
Parameters
__namedParameters
SpringProps<T>
isLoop?
boolean
Returns
AsyncResult<SpringValue<T>>
advance()
advance(
dt):void
Advance the current animation by a number of milliseconds
Parameters
dt
number
Returns
void
Overrides
eventObserved()
eventObserved(
event):void
Internal
Parameters
event
Returns
void
Overrides
finish()
finish():
this
Skip to the end of the current animation.
Returns
this
get()
get():
T
Get the current value
Returns
T
Inherited from
interpolate()
interpolate<
Out>(...args):Interpolation<T,Out>
Type Parameters
Out
Out
Parameters
args
...InterpolatorArgs<T, Out>
Returns
Interpolation<T, Out>
Deprecated
Use the to method instead.
Inherited from
observerAdded()
protectedobserverAdded(count):void
Called after an observer is added.
Parameters
count
number
Returns
void
Inherited from
observerRemoved()
protectedobserverRemoved(count):void
Called after an observer is removed.
Parameters
count
number
Returns
void
Inherited from
pause()
pause():
void
Freeze the active animation in time, as well as any updates merged before resume is called.
Returns
void
reset()
reset():
void
Restart the animation.
Returns
void
resume()
resume():
void
Resume the animation if paused.
Returns
void
set()
set(
value):this
Set the current value, while stopping the current animation
Parameters
value
T | FluidValue<T, any>
Returns
this
start()
Call Signature
start():
AsyncResult<SpringValue<T>>
Update this value's animation using the queue of pending props, and unpause the current animation (if one is frozen).
When arguments are passed, a new animation is created, and the queued animations are left alone.
Returns
AsyncResult<SpringValue<T>>
Call Signature
start(
props):AsyncResult<SpringValue<T>>
Update this value's animation using the queue of pending props, and unpause the current animation (if one is frozen).
When arguments are passed, a new animation is created, and the queued animations are left alone.
Parameters
props
SpringUpdate<T>
Returns
AsyncResult<SpringValue<T>>
Call Signature
start(
to,props?):AsyncResult<SpringValue<T>>
Update this value's animation using the queue of pending props, and unpause the current animation (if one is frozen).
When arguments are passed, a new animation is created, and the queued animations are left alone.
Parameters
to
T
props?
SpringProps<T>
Returns
AsyncResult<SpringValue<T>>
stop()
stop(
cancel?):this
Stop the current animation, and cancel any delayed updates.
Pass true to call onRest with cancelled: true.
Parameters
cancel?
boolean
Returns
this
to()
to<
Out>(...args):Interpolation<T,Out>
Create a spring that maps our value to another value
Type Parameters
Out
Out
Parameters
args
...InterpolatorArgs<T, Out>
Returns
Interpolation<T, Out>
Inherited from
toJSON()
toJSON():
T
Returns
T
Inherited from
update()
update(
props):this
Push props into the pending queue.
Parameters
props
SpringUpdate<T>
Returns
this