Skip to content

Commit 6bfe358

Browse files
committed
spring API
1 parent 02a2340 commit 6bfe358

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,36 @@ const MyComponent = () => (
8787

8888
## API
8989
### `spring(start, target, options)`
90+
91+
This method creates spring-based keyframes. Called with start and target properties, it returns an object with the interpolated animation values.
92+
93+
#### Arguments
94+
95+
- `start` (_Object_): The start properties for the animation. The keys should be css properties, the values should be able to be parsed to a number by `parseFloat`. Keys that can not be parsed or do not exist in the target properties are ignored.
96+
- `target` (_Object_): The target properties for the animation. The keys should be css properties, the values should be able to be parsed to a number by `parseFloat`. Keys that can not be parsed or do not exist in the start properties are ignored.
97+
- `options` (_Object_, optional): Animation options with these properties:
98+
- `precision` (_Number_, optional, defaults to `3`) Specifies the number of decimals in the rounding of interpolated values.
99+
- `preset` (_String_, optional): Presets for `stiffness` and `damping`, overriding any stiffness and damping values given. Available presets:
100+
- `stiff` stiffness 210, damping 20
101+
- `gentle` stiffness 120, damping 14
102+
- `wobbly` stiffness 180, damping 12
103+
- `noWobble` stiffness 170, damping 26
104+
- `stiffness` (_Number_, optional, default: 170): The stiffness of your spring-based animation.
105+
- `damping` (_Number_, optional, default: 26): The damping of your spring-based animation.
106+
107+
#### Returns
108+
109+
An object with `0%` to `100%` keys and the interpolated physics-based values for each step of the animation, e.g.:
110+
111+
```javascript
112+
{
113+
"0%": { "left": 0 },
114+
"1%": { "left": 3 },
115+
"1%": { "left": 8.544 },
116+
// 2% … 98%
117+
"99%": { "left": 249.981 }
118+
"100%": { "left": 250 }
119+
}
120+
```
121+
90122
### `format(keyframes, formatter)`

0 commit comments

Comments
 (0)