MCPcopy
hub / github.com/pmndrs/react-spring / SpringValue

Class SpringValue

packages/core/src/SpringValue.ts:78–1053  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76 * Non-animatable strings are also supported.
77 */
78export class SpringValue<T = any> extends FrameValue<T> {
79 /** The property name used when `to` or `from` is an object. Useful when debugging too. */
80 key?: string
81
82 /** The animation state */
83 animation = new Animation<T>()
84
85 /** The queue of pending props */
86 queue?: SpringUpdate<T>[]
87
88 /** Some props have customizable default values */
89 defaultProps: DefaultSpringProps<T> = {}
90
91 /** The state for `runAsync` calls */
92 protected _state: RunAsyncState<SpringValue<T>> = {
93 paused: false,
94 delayed: false,
95 pauseQueue: new Set(),
96 resumeQueue: new Set(),
97 timeouts: new Set(),
98 }
99
100 /** The promise resolvers of pending `start` calls */
101 protected _pendingCalls = new Set<AnimationResolver<this>>()
102
103 /** The counter for tracking `scheduleProps` calls */
104 protected _lastCallId = 0
105
106 /** The last `scheduleProps` call that changed the `to` prop */
107 protected _lastToId = 0
108
109 protected _memoizedDuration = 0
110
111 constructor(from: Exclude<T, object>, props?: SpringUpdate<T>)
112 constructor(props?: SpringUpdate<T>)
113 constructor(arg1?: any, arg2?: any) {
114 super()
115 if (!is.und(arg1) || !is.und(arg2)) {
116 const props = is.obj(arg1) ? { ...arg1 } : { ...arg2, from: arg1 }
117 if (is.und(props.default)) {
118 props.default = true
119 }
120 this.start(props)
121 }
122 }
123
124 /** Equals true when not advancing on each frame. */
125 get idle() {
126 return !(isAnimating(this) || this._state.asyncTo) || isPaused(this)
127 }
128
129 get goal() {
130 return getFluidValue(this.animation.to) as T
131 }
132
133 get velocity(): VelocityProp<T> {
134 const node = getAnimated(this)!
135 return (

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…