Skip to content

Commit c97f180

Browse files
committed
2 parents 2b8c683 + 0a87f09 commit c97f180

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

readme.md

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,15 @@
44

55
# Why 🤔
66

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:
7+
React-spring is a cooked down fork of [Facebooks animated](https://github.com/animatedjs/animated). It is trying to bridge it with Chenglou's [React-motion](https://github.com/chenglou/react-motion) because both have their pros and cons and could definitively benefit from one another:
88

9-
#### React-motion
9+
| | Declarative | Primitives | Interpolations | Performance |
10+
|----------------|-------------|----------------|----------------|-------------|
11+
| React-motion   | ✅ | ✅ | ❌ | ❌
12+
| Animated       | ❌ | ❌ | ✅ | ✅
13+
| React-spring   | ✅ | ✅ | ✅ | ✅
1014

11-
* [x] Declarative api that doesn't involve manual management of animations
12-
* [x] Covers most of the essentials (springs, lists, transitions, reveals, staggered animations)
13-
* [ ] Performance can suffer because components are re-rendered every frame with fresh props
14-
* [ ] Can't interpolate between raw state as it doesn't know colors, paths, gradients, etc.
15-
16-
#### Animated
17-
18-
* [x] Interpolates most web privimites, units and patterns
19-
* [x] Efficiently writes to the dom directly instead of re-rendering components frame by frame
20-
* [ ] Managing and orchestrating handles (starting/stopping/waiting/cleaning) can become a real chore
21-
* [ ] Missing essential prototypes like mount/unmount transitions
22-
23-
As you see, they're polar opposites. React-spring inherits React-motions api, but simplified, while adding more primitives and being able to interpolate. It also has support for native rendering, where components animate directly in the dom.
15+
React-spring inherits react-motions api (and simplifies it), has lots of primitives (springs, trails, transitions, reveals, parallax), can interpolate mostly everything (colors, gradients, percentages, degrees, svg-paths, arrays, etc.) and last but not least, can animate by committing directly to the dom instead of re-rendering a component frame-by-frame.
2416

2517
# Overview 🔭
2618

@@ -100,7 +92,7 @@ Given a single child instead of a list you can reveal components with it.
10092
</Parallax>
10193
```
10294

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)
95+
#### Additional demos: [Vertical scroll](https://codesandbox.io/embed/0oonqxnpjl) | [Animated graphs](https://codesandbox.io/embed/j3x61vjz5v)[Button slider](https://codesandbox.io/embed/jzn14k0ppy) | [Animated todoMVC](https://codesandbox.io/embed/2pk8l7n7kn)[Drag n drop](https://codesandbox.io/embed/l9zqz0m18z)
10496

10597
# API overview 📖
10698

@@ -112,30 +104,32 @@ You can interpolate almost everything, from numbers, colors, svg-paths, percenta
112104

113105
```jsx
114106
<spring to={{
107+
scale: toggle ? 1 : 2,
115108
start: toggle ? '#abc' : 'rgb(10,20,30)',
116109
end: toggle ? 'seagreen' : 'rgba(0,0,0,0.5)',
117110
stop: toggle ? '0%' : '50%',
118-
scale: toggle ? 1 : 2,
119111
rotate: toggle ? '0deg' : '45deg',
120-
path: toggle ? 'M20,380 L380,380 L380,380 Z' : 'M20,20 L20,380 L380,380 Z' }}>
112+
path: toggle ? 'M20,380 L380,380 L380,380 Z' : 'M20,20 L20,380 L380,380 Z',
113+
vector: toggle ? [1,2,50,100] : [20,30,1,-100],
114+
}}>
121115
```
122116

123117
### Render props
124118

125119
Don't like the way render props wrap your code?
126120

127121
```jsx
128-
const Header = ({ children, ...styles }) => (
122+
const Header = ({ children, bold, ...styles }) => (
129123
<h1 style={styles}>
130124
{children}
131125
</h1>
132126
)
133127

134-
const App = ({ color, children }) => (
135-
<Spring to={{ color }} render={Header}>
136-
{children}
137-
</Spring>
138-
)
128+
129+
<Spring to={{ color: 'fuchsia' }} render={Header}>
130+
{children}
131+
</Spring>
132+
139133
```
140134

141135
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.
@@ -146,7 +140,7 @@ By default we'll render the receiving component every frame as it gives you more
146140

147141
Just be aware of the following conditions:
148142

149-
1. It only animates standard styles and element props, the values you receive *are opaque objects, not regular values*
143+
1. It only animates element styles and attributes, the values you receive *are opaque objects, not regular values*
150144
2. Receiving elements must be `animated.[elementName]`, for instance `div` becomes `animated.div`
151145
3. If you need to interpolate styles use the `template` string literal
152146

0 commit comments

Comments
 (0)