Skip to content

Commit 2bb11da

Browse files
committed
fix docz build
1 parent e96ade5 commit 2bb11da

File tree

7 files changed

+34
-37
lines changed

7 files changed

+34
-37
lines changed

documentation/useChain.mdx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,36 @@ import examples from '../examples/components/examples-hooks'
1414
import { useChain, animated } from 'react-spring'
1515
```
1616

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.
1818

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.
2220

2321
```jsx
24-
const springs = useSprings(items.length, items.map(item => ({ opacity: item.opacity }))
22+
// Build a spring and catch its ref
23+
const springRef = useRef()
24+
const props = useSpring({ ...values, ref: springRef })
25+
// Build a transition and catch its ref
26+
const transitionRef = useRef()
27+
const transitions = useTransition({ ...values, ref: transitionRef })
28+
// 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+
)
2537
```
2638

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.
3040

3141
```jsx
32-
const [springs, set] = useSprings(items.length, index => ({ opacity: items[index].opacity }))
33-
// ...
34-
set(index => ({ opacity: items[index].opacity }))
42+
// The spring will start right away
43+
// The transition will start after 0.5 * 1000ms (the timeFrame default) = 500ms
44+
useChain([springRef, transitionRef], [0, 0.5])
3545
```
3646

37-
### Finally: distribute animated props among the view
38-
39-
The return value is an array containing animated props.
40-
41-
```jsx
42-
return springs.map(item => <animated.div style={props} />)
43-
```
44-
45-
## Properties
46-
47-
All properties of the [shared-api](/api) apply.
48-
4947
## Demos
5048

5149
<DemoGrid padding={0}>

documentation/useSprings.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ set(index => ({ opacity: items[index].opacity }))
3939
The return value is an array containing animated props.
4040
4141
```jsx
42-
return springs.map(item => <animated.div style={props} />)
42+
return springs.map(props => <animated.div style={props} />)
4343
```
4444
4545
## Properties

documentation/useTrail.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,32 @@ import examples from '../examples/components/examples-hooks'
1414
import { useTrail, animated } from 'react-spring'
1515
```
1616

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.
1818

1919
### Either: overwrite values to change the animation
2020

2121
If you re-render the component with changed props, the animation will update.
2222

2323
```jsx
24-
const springs = useSprings(items.length, items.map(item => ({ opacity: item.opacity }))
24+
const trail = useTrail(items.length, { opacity: 1, from: { opacity: 0 } })
2525
```
2626

2727
### Or: pass a function that returns values, and update using "set"
2828

2929
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.
3030

3131
```jsx
32-
const [springs, set] = useSprings(items.length, index => ({ opacity: items[index].opacity }))
32+
const [trail, set] = useTrail(items.length, () => ({ opacity: 1, from: { opacity: 0 } }))
3333
// ...
34-
set(index => ({ opacity: items[index].opacity }))
34+
set({ opacity: 0 })
3535
```
3636

3737
### Finally: distribute animated props among the view
3838

3939
The return value is an array containing animated props.
4040

4141
```jsx
42-
return springs.map(item => <animated.div style={props} />)
42+
return trail.map(props => <animated.div style={props} />)
4343
```
4444

4545
## Properties

doczrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default {
148148
...config.module,
149149
rules: [
150150
...config.module.rules,
151-
//{ test: () => true, sideEffects: true },
151+
{ test: () => true, sideEffects: true },
152152
],
153153
},
154154
resolve: {

examples/CNAME

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
react-spring.surge.sh
1+
react-spring-hooks.surge.sh

examples/demos/chain-animation/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function App() {
1616
const springRef = useRef()
1717
const { size, opacity, ...rest } = useSpring({
1818
from: { size: '20%', background: 'hotpink' },
19-
size: open ? '100%' : '20%',
19+
size: open ? '80%' : '20%',
2020
background: open ? 'white' : 'hotpink',
2121
config: { ...config.stiff, precision: 0.01 },
2222
ref: springRef,
@@ -61,19 +61,21 @@ const Main = styled('div')`
6161
align-items: center;
6262
justify-content: center;
6363
padding: 20px;
64+
box-sizing: border-box;
6465
`
6566

6667
const Sidebar = styled(animated.div)`
6768
position: relative;
6869
display: grid;
69-
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
70+
grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
7071
grid-gap: 20px;
7172
padding: 20px;
7273
background: white;
7374
border-radius: 5px;
7475
cursor: pointer;
7576
will-change: width, height;
7677
box-shadow: 0px 10px 10px -5px rgba(0, 0, 0, 0.05);
78+
box-sizing: border-box;
7779
`
7880

7981
const Content = styled(animated.div)`
@@ -93,8 +95,5 @@ const Item = styled(animated.div)`
9395
height: 100%;
9496
background: white;
9597
border-radius: 5px;
96-
background-image: url(https://images.unsplash.com/photo-1544511916-0148ccdeb877?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1901&q=80i);
97-
background-size: cover;
98-
background-position: center center;
9998
will-change: transform, opacity;
10099
`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"prebuild": "rimraf dist",
1212
"docz": "docz dev",
13-
"docz:build": "docz build",
13+
"docz:build": "docz build && cp .docz/dist/index.html .docz/dist/200.html && cp examples/CNAME .docz/dist/CNAME",
1414
"build": "npm-run-all --parallel copy rollup",
1515
"copy": "copyfiles -f package.json readme.md LICENSE.md \"types/*\" dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.scripts=undefined; this.husky=undefined; this.prettier=undefined; this.jest=undefined; this['lint-staged'] = undefined;\"",
1616
"rollup": "rollup -c",

0 commit comments

Comments
 (0)