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

Function advance

packages/shared/src/FrameLoop.ts:91–118  ·  view source on GitHub ↗
(dt: number)

Source from the content-addressed store, hash-verified

89}
90
91function advance(dt: number) {
92 const nextFrame = prevFrame
93
94 for (let i = 0; i < currentFrame.length; i++) {
95 const animation = currentFrame[i]
96 priority = animation.priority
97
98 // Animations may go idle before advancing.
99 if (!animation.idle) {
100 G.willAdvance(animation)
101 animation.advance(dt)
102 if (!animation.idle) {
103 nextFrame.push(animation)
104 }
105 }
106 }
107 priority = 0
108
109 // Reuse the `currentFrame` array to avoid garbage collection.
110 prevFrame = currentFrame
111 prevFrame.length = 0
112
113 // Set `currentFrame` for next frame, so the `start` function
114 // adds new animations to the proper array.
115 currentFrame = nextFrame
116
117 return currentFrame.length > 0
118}
119
120/** Like `Array.prototype.findIndex` but returns `arr.length` instead of `-1` */
121function findIndex<T>(arr: T[], test: (value: T) => boolean) {

Callers 1

useSpring.test.tsxFile · 0.85

Calls 1

advanceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…