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

Method eventObserved

packages/core/src/Interpolation.ts:134–159  ·  view source on GitHub ↗

@internal

(event: FrameValue.Event)

Source from the content-addressed store, hash-verified

132
133 /** @internal */
134 eventObserved(event: FrameValue.Event) {
135 // Update our value when an idle parent is changed,
136 // and enter the frameloop when a parent is resumed.
137 if (event.type == 'change') {
138 if (event.idle) {
139 this.advance()
140 } else {
141 this._active.add(event.parent)
142 this._start()
143 }
144 }
145 // Once all parents are idle, the `advance` method runs one more time,
146 // so we should avoid updating the `idle` status here.
147 else if (event.type == 'idle') {
148 this._active.delete(event.parent)
149 }
150 // Ensure our priority is greater than all parents, which means
151 // our value won't be updated until our parents have updated.
152 else if (event.type == 'priority') {
153 this.priority = toArray(this.source).reduce(
154 (highest: number, parent) =>
155 Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1),
156 0
157 )
158 }
159 }
160}
161
162/** Returns true for an idle source. */

Callers

nothing calls this directly

Calls 6

advanceMethod · 0.95
_startMethod · 0.95
toArrayFunction · 0.90
isFrameValueFunction · 0.90
addMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected