Skip to content

Commit b4758d3

Browse files
committed
Update docs
1 parent 8dd538c commit b4758d3

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

README.md

+17-19
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
[![Code Coverage](https://img.shields.io/coveralls/codepunkt/css-spring/master.svg?style=flat&label=Code%20Coverage)](https://coveralls.io/github/codepunkt/css-spring?branch=master)
66
[![MIT License](https://img.shields.io/npm/l/css-spring.svg?style=flat&label=License)](http://opensource.org/licenses/MIT)
77

8-
Generate physics based css-keyframe animations for the css-in-js solution of your choice or plain css.
8+
#### Generate physics based css keyframe animation objects or strings for the css-in-js solution of your choice.
9+
##### Works with simple numeric css properties (with units or without), combined properties such as padding and rgb hex colors. Eliminates duplicate values and unused keyframes to optimize animation size.
10+
11+
#### *~3kb gzipped.*
912

1013
<table>
1114
<tr>
@@ -94,27 +97,20 @@ This method creates spring-based keyframes. Called with `startProp` and `targetP
9497
reflecting the starting and ending properties of the animation, it returns an object with the
9598
interpolated animation values.
9699

97-
The following properties in both the `startProp` and `endProp` objects are ignored when
98-
calculating the animation:
99-
100-
- properties that do not exist in both arguments
101-
- properties that have non-numeric values
102-
- properties with units that differ between both arguments
103-
104100
#### Arguments
105101

106102
- `startProps` (_Object_): The start properties for the animation.<br>
107103

108104
```javascript
109105
// `startProps` example
110-
{ 'margin-left': '0px', opacity: 0 }
106+
{ 'margin-left': '0px', opacity: 0, background: '#f00' }
111107
```
112108

113109
- `endProps` (_Object_): The end properties for the animation.<br>
114110

115111
```javascript
116112
// `endProps` example
117-
{ 'margin-left': '250px', opacity: 1 }
113+
{ 'margin-left': '250px', opacity: 1, background: '#bada55' }
118114
```
119115

120116
- `options` (_Object_, optional): Animation options with these properties:
@@ -129,19 +125,21 @@ calculating the animation:
129125

130126
#### Returns
131127

132-
An object with `0%` to `100%` keys and the interpolated physics-based values for each step of the animation, e.g.:
128+
An object with keyframes between `0%` and `100%`, having the interpolated values for each step of the animation, e.g.:
133129

134130
```javascript
135131
{
136-
"0%": { "margin-left": "0px" },
137-
"1%": { "margin-left": "3px" },
138-
"2%": { "margin-left": "8.544px" },
139-
// 3% … 98%
140-
"99%": { "margin-left": "249.981px" }
141-
"100%": { "margin-left": "250px" }
132+
'0%': { 'margin-left': '5px', opacity: 0.02, background: '#fe0402' },
133+
'1%': { 'margin-left': '13px', opacity: 0.05, background: '#fb0b04' },
134+
'2%': { 'margin-left': '25px', opacity: 0.1, background: '#f81508' },
135+
// meaningful frames between 2% and 88%
136+
'88%': { 'margin-left': '250px' },
137+
'100%': { 'margin-left': '250px', opacity: 1, background: '#bada55' }
142138
}
143139
```
144140

141+
Redundant values and empty keyframes are removed to optimize the size of the resulting css. There is simply no point in having a `margin-left` value of `'250px'` in every keyframe ranging from 88% to 100%.
142+
145143
### `toString(keyframes, formatter)`
146144

147145
This method takes the return value of `spring` and converts it to a css string.
@@ -192,7 +190,7 @@ This would net you the following css:
192190

193191
There's a lot of ideas floating in my head that could make working with **css-spring** easier. Some of these are:
194192
195-
- allowing the interpolation of array values like margins, paddings or translates ([#1](/../../issues/1))
196-
- color interpolation ([#3](/../../issues/3))
193+
- adding a plugin system to use things such as autoprefixer or cssnano minification ([#8](/../../issues/8))
194+
- a commandline to generate spring keyframe animations for usage in your css files ([#4](/../../issues/4))
197195
198196
Feel free to contribute with your own issues and ideas, your thoughts on the ones listed above, example documentation for usage with other css-in-js frameworks or pull requests for features/improvements you'd like to see.

0 commit comments

Comments
 (0)