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

Method _set

packages/core/src/SpringValue.ts:936–957  ·  view source on GitHub ↗

* Update the current value from outside the frameloop, * and return the `Animated` node.

(arg: T | FluidValue<T>, idle = true)

Source from the content-addressed store, hash-verified

934 * and return the `Animated` node.
935 */
936 protected _set(arg: T | FluidValue<T>, idle = true): Animated | undefined {
937 const value = getFluidValue(arg)
938 if (!is.und(value)) {
939 const oldNode = getAnimated(this)
940 if (!oldNode || !isEqual(value, oldNode.getValue())) {
941 // Create a new node or update the existing node.
942 const nodeType = getAnimatedType(value)
943 if (!oldNode || oldNode.constructor != nodeType) {
944 setAnimated(this, nodeType.create(value))
945 } else {
946 oldNode.setValue(value)
947 }
948 // Never emit a "change" event for the initial value.
949 if (oldNode) {
950 raf.batchedUpdates(() => {
951 this._onChange(value, idle)
952 })
953 }
954 }
955 }
956 return getAnimated(this)
957 }
958
959 protected _onStart() {
960 const anim = this.animation

Callers 4

setMethod · 0.95
finishMethod · 0.95
_prepareNodeMethod · 0.95
_mergeMethod · 0.95

Calls 9

_onChangeMethod · 0.95
getFluidValueFunction · 0.90
getAnimatedFunction · 0.90
isEqualFunction · 0.90
getAnimatedTypeFunction · 0.90
setAnimatedFunction · 0.90
getValueMethod · 0.45
createMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected