Skip to content

Commit 9449dc6

Browse files
committed
2 parents 1c57dd6 + ca410b8 commit 9449dc6

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

readme.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Why 🤔
66

7-
React-spring is a wrapper around a cooked down fork of [Facebooks animated](http://animatedjs.github.io/interactive-docs/). It is trying to cross it with Chenglou's [React-motion](https://github.com/chenglou/react-motion). Both have their pros and cons and could benefit from one another:
7+
React-spring is a cooked down fork of [Facebooks animated](http://animatedjs.github.io/interactive-docs/). It is trying to bridge it with Chenglou's [React-motion](https://github.com/chenglou/react-motion) because both have their pros and cons but could definitively benefit from one another:
88

99
#### React-motion
1010

@@ -25,14 +25,16 @@ As you see, they're polar opposites. React-spring inherits React-motions api, bu
2525
# Overview 🔭
2626

2727
<p align="middle">
28-
<img src="assets/spring.gif" width="280" />
29-
<img src="assets/transition.gif" width="280" />
30-
<img src="assets/reveal.gif" width="280" />
28+
<img src="assets/spring.gif" width="430" />
29+
<img src="assets/transition.gif" width="430" />
3130
</p>
3231
<p align="middle">
33-
<img src="assets/trail.gif" width="280" />
34-
<img src="assets/scroll.gif" width="280" />
35-
<img src="assets/parallax.gif" width="280" />
32+
<img src="assets/reveal.gif" width="430" />
33+
<img src="assets/trail.gif" width="430" />
34+
</p>
35+
<p align="middle">
36+
<img src="assets/scroll.gif" width="430" height="222.88" />
37+
<img src="assets/parallax.gif" width="430" />
3638
</p>
3739

3840
```jsx
@@ -44,9 +46,7 @@ import { Spring, Transition, Trail, Parallax } from 'react-spring'
4446
A `Spring` will move data from one state to another. It remembers the current state, value changes are always fluid.
4547

4648
```jsx
47-
<Spring
48-
from={{ opacity: 0 }}
49-
to={{ opacity: 1 }}>
49+
<Spring from={{ opacity: 0 }} to={{ opacity: 1 }}>
5050
{styles => <div style={styles}>i will fade in</div>}
5151
</Spring>
5252
```
@@ -57,11 +57,11 @@ A `Spring` will move data from one state to another. It remembers the current st
5757

5858
```jsx
5959
<Transition
60-
keys={toggle ? 'ComponentA' : 'ComponentB'}
61-
from={{ opacity: 0 }}
62-
enter={{ opacity: 1 }}
63-
leave={{ opacity: 0 }}>
64-
{toggle ? ComponentA : ComponentB}
60+
keys={items.map(item => item.key)}
61+
from={{ opacity: 0, height: 0 }}
62+
enter={{ opacity: 1, height: 20 }}
63+
leave={{ opacity: 0, height: 0 }}>
64+
{items.map(item => styles => <li style={styles}>{item.text}</li>)}
6565
</Transition>
6666
```
6767

@@ -71,7 +71,7 @@ Given a single child instead of a list you can reveal components with it.
7171

7272
```jsx
7373
<Transition
74-
keys={toggle ? 'ComponentA' : 'ComponentB'}
74+
keys={toggle ? 'A' : 'B'}
7575
from={{ opacity: 0 }}
7676
enter={{ opacity: 1 }}
7777
leave={{ opacity: 0 }}>
@@ -84,10 +84,7 @@ Given a single child instead of a list you can reveal components with it.
8484
`Trail` animates the first child of a list of elements, the rest follow the spring of their previous sibling.
8585

8686
```jsx
87-
<Trail
88-
from={{ opacity: 0 }}
89-
to={{ opacity: 1 }}
90-
keys={items.map(item => item.key)}>
87+
<Trail from={{ opacity: 0 }} to={{ opacity: 1 }} keys={items.map(item => item.key)}>
9188
{items.map(item => styles => <div style={styles}>{item.text}</div>)}
9289
</Trail>
9390
```
@@ -103,11 +100,13 @@ Given a single child instead of a list you can reveal components with it.
103100
</Parallax>
104101
```
105102

106-
#### Additional demos: [TodoMVC](https://codesandbox.io/embed/2pk8l7n7kn) | [DragList](https://codesandbox.io/embed/l9zqz0m18z)[Graphs](https://codesandbox.io/embed/j3x61vjz5v)
103+
#### Additional demos: [Vertical scroll](https://codesandbox.io/embed/0oonqxnpjl) | [Animated graphs](https://codesandbox.io/embed/j3x61vjz5v)[Animated todoMVC](https://codesandbox.io/embed/2pk8l7n7kn)[Drag n drop](https://codesandbox.io/embed/l9zqz0m18z)
107104

108-
# API 📖
105+
# API overview 📖
109106

110-
## Springs and default rendering
107+
For a raw documentation of all possible properties look [here](https://github.com/drcmda/react-spring/blob/master/API.md).
108+
109+
### Springs and interpolation
111110

112111
You can interpolate almost everything, from numbers, colors, svg-paths, percentages, arrays to string patterns:
113112

@@ -121,6 +120,8 @@ You can interpolate almost everything, from numbers, colors, svg-paths, percenta
121120
path: toggle ? 'M20,380 L380,380 L380,380 Z' : 'M20,20 L20,380 L380,380 Z' }}>
122121
```
123122

123+
### Render props
124+
124125
Don't like the way render props wrap your code?
125126

126127
```jsx
@@ -139,7 +140,7 @@ const App = ({ color, children }) => (
139140

140141
Et voilà! `Header` animates on prop changes! Props that `Spring` doesn't recognize will be spread over the receiving component, including `children` if you use `render` to refer to the render-child.
141142

142-
## Native rendering ([Demo](https://codesandbox.io/embed/882njxpz29))
143+
### Native rendering ([Demo](https://codesandbox.io/embed/882njxpz29))
143144

144145
By default we'll render the receiving component every frame as it gives you more freedom to animate. In situations where that becomes expensive add the `native` flag and animations will now be applied directly to the dom. The flag is available for all primitives (Spring, Transition & Trail, Parallax is native by design).
145146

@@ -161,9 +162,9 @@ import { Spring, animated, template } from 'react-spring'
161162
</Spring>
162163
```
163164

164-
## Transitions
165+
### Transitions
165166

166-
Animates children as they mount and unmount. `from` denotes base styles, `enter` styles are applied when objects appear, `leave` styles are applied when objects disappear. Keys and children have to match in their order!
167+
Animates children as they mount and unmount. `from` denotes base styles, `enter` styles are applied when objects appear, `leave` styles are applied when objects disappear. Keys and children have to match in their order! The keys are the same that you would provide in any other looping situation.
167168

168169
```jsx
169170
import { Transition } from 'react-spring'
@@ -191,7 +192,7 @@ You can use this prototype for two-state reveals, simply render a single child t
191192
</Transition>
192193
```
193194

194-
## Trails/Staggered transitions
195+
### Trails/Staggered transitions
195196

196197
`Trail` animates the first child of the list you pass, the others will follow in a trailing motion. The api is similar to `Transition` though it will assume your list is fixed.
197198

@@ -203,9 +204,9 @@ import { Trail } from 'react-spring'
203204
</Trail>
204205
```
205206

206-
## Parallax and page transitions
207+
### Parallax and page transitions
207208

208-
`Parallax` creates a scroll container. Throw in any amount of layers and it will take care of moving them in accordance to their offsets and scrolling speeds.
209+
`Parallax` creates a scroll container. Throw in any amount of layers and it will take care of moving them in accordance to their offsets and speeds.
209210

210211
`Parallax.pages` determines the total space of the inner content where each page takes 100% of the visible container. `Layer.offset` determines where the layer will be at when scrolled to (0=start, 1=1st page, ...). `Layer.speed` shifts the layer in accordance to its offset, values can be positive or negative.
211212

@@ -214,7 +215,7 @@ import { Parallax } from 'react-spring'
214215

215216
<Parallax pages={3} scrolling={false} horizontal ref={ref => this.parallax = ref}>
216217
<Parallax.Layer offset={0} speed={0.5}>
217-
<span onClick={() => this.parallax.scrollTo(1)}>>
218+
<span onClick={() => this.parallax.scrollTo(1)}>
218219
Layers can contain anything
219220
</span>
220221
</Parallax.Layer>

0 commit comments

Comments
 (0)