You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/useChain.mdx
+21-23Lines changed: 21 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,38 +14,36 @@ import examples from '../examples/components/examples-hooks'
14
14
import { useChain, animated } from'react-spring'
15
15
```
16
16
17
-
useSprings manages multiple springs. Use it whenever you have an arry of values that you want to animate (static lists, etc). It behaves exactly like [useSpring](/useSpring) with the distinction that you supply a count as the first argument, while the spring config is given for each item, either functionally, or as an array.
17
+
The useChain hook allows you to set the execution order of previously defined animation-hooks, where one animation starts after the other in sequence. In order to do this you have to collect refs off the hooks you want to chain. A ref contains a managing instance with start/stop functionality (which you could call yourself if you wanted to). A hook that has given its ref will not start on its own from there on. The order in which you animate can be changed in subsequent render passes.
18
18
19
-
### Either: overwrite values to change the animation
20
-
21
-
If you re-render the component with changed props, the animation will update.
19
+
useChain does not change how you form your views otherwise, you can use the output you get from animation-hooks in the same manner as before.
// First run the spring, when it concludes run the transition
29
+
useChain([springRef, transitionRef])
30
+
// Use the animated props like always
31
+
return (
32
+
<animated.div style={props}>
33
+
{transitions.map(({ item, key, props }) =>
34
+
<animated.div key={key} style={props} />)}
35
+
</animated.div>
36
+
)
25
37
```
26
38
27
-
### Or: pass a function that returns values, and update using "set"
28
-
29
-
You will get a `set(Values)` function back, use it to update the animation. This will not cause the component to render, which can be generally more performant. It also prevents configs from being re-created on every render. Handling updates like this is extremely useful for fast-occurring updates, like event streams, mousemoves, etc.
39
+
If a sequence isn't what you want you can optionally define timeSteps and a timeFrame (which defaults to a second). timeSteps is just an array with offsets between 0-1 that correspend to beginning and the end of the timeFrame.
Copy file name to clipboardExpand all lines: documentation/useTrail.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,32 +14,32 @@ import examples from '../examples/components/examples-hooks'
14
14
import { useTrail, animated } from'react-spring'
15
15
```
16
16
17
-
useSprings manages multiple springs. Use it whenever you have an arry of values that you want to animate (static lists, etc). It behaves exactly like [useSpring](/useSpring) with the distinction that you supply a count as the first argument, while the spring config is given for each item, either functionally, or as an array.
17
+
useTrail needs the amount of items you want to trail and the props you want to animate. It returns an array of animated-props, which you can then distribute among your views.
18
18
19
19
### Either: overwrite values to change the animation
20
20
21
21
If you re-render the component with changed props, the animation will update.
### Or: pass a function that returns values, and update using "set"
28
28
29
29
You will get a `set(Values)` function back, use it to update the animation. This will not cause the component to render, which can be generally more performant. It also prevents configs from being re-created on every render. Handling updates like this is extremely useful for fast-occurring updates, like event streams, mousemoves, etc.
0 commit comments