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

Function animate

packages/core/src/runAsync.ts:101–145  ·  view source on GitHub ↗
(arg1: any, arg2?: any)

Source from the content-addressed store, hash-verified

99 const SKIP_ANIMATION_CALL_LIMIT = 1024
100
101 const animate: any = (arg1: any, arg2?: any) => {
102 // Create the bail signal outside the returned promise,
103 // so the generated stack trace is relevant.
104 const bailSignal = new BailSignal()
105 const skipAnimationSignal = new SkipAnimationSignal()
106
107 return (async () => {
108 bailIfEnded(bailSignal)
109
110 const props: any = is.obj(arg1) ? { ...arg1 } : { ...arg2, to: arg1 }
111 props.parentId = callId
112
113 eachProp(defaultProps, (value, key) => {
114 if (is.und(props[key])) {
115 props[key] = value
116 }
117 })
118
119 if (G.skipAnimation) {
120 if (++skipAnimationCallCount > SKIP_ANIMATION_CALL_LIMIT) {
121 stopAsync(state)
122 skipAnimationSignal.result = getFinishedResult(target, false)
123 bail(skipAnimationSignal)
124 throw skipAnimationSignal
125 }
126
127 // Apply each step immediately so the script can run to completion
128 // and the spring lands on whatever value the final `next(...)` call
129 // would set under normal animation.
130 props.immediate = true
131 return await target.start(props)
132 }
133
134 const result = await target.start(props)
135 bailIfEnded(bailSignal)
136
137 if (state.paused) {
138 await new Promise<void>(resume => {
139 state.resumeQueue.add(resume)
140 })
141 }
142
143 return result
144 })()
145 }
146
147 let result!: AnimationResult<T>
148

Callers 3

Controller.test.tsFile · 0.85
runAsyncFunction · 0.85
handleValueChangeFunction · 0.85

Calls 6

eachPropFunction · 0.90
getFinishedResultFunction · 0.90
bailIfEndedFunction · 0.85
stopAsyncFunction · 0.85
addMethod · 0.80
startMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…