aninest-root / Animatable / getLocalState
getLocalState()
ts
function getLocalState<Animating>(
anim,
into,
skipFrom): SlicedAnimatable<Animating>;
Defined in: Animate/Animatable.ts:334
Gets the current local state of the animation, meaning only the strings and numbers in the topmost level of the animation. To access the local state of a child, use anim.children.childName
as the input. Numbers will smoothly interpolate from the starting to the ending value while strings will snap to the ending value once the animation is at least 50% complete.
Type Parameters
Animating
Animating
extends Animatable
<unknown
>
Parameters
anim
Animation
<Animating
>
The animation object
into
SlicedAnimatable
<Animating
> = ...
skipFrom
boolean
= false
Returns
SlicedAnimatable
<Animating
>
The local state of the animation
Examples
ts
const anim = createAnimation({a: newVec2(0, 0), b: newVec2(1, 1)}, getLinearInterp(1))
const localState = getLocalState(anim) // {}
const localStateA = getLocalState(anim.children.a) // {x: 0, y: 0}
const localStateB = getLocalState(anim.children.b) // {x: 1, y: 1}
ts
const anim = createAnimation({ a: newVec2(0, 0), b: 1 }, NO_INTERP)
const localState = getLocalState(anim) // { b: 1 }
const localStateA = getLocalState(anim.children.a) // { x: 0, y: 0 }