├── .babelrc ├── .eslintignore ├── .eslintrc.js ├── .flowconfig ├── .gitignore ├── .npmignore ├── LICENSE.txt ├── Procfile ├── README.md ├── demo ├── .eslintrc.js ├── app.js ├── demo.js ├── index.html ├── server.js └── webpack.config.js ├── package.json ├── src ├── __tests__ │ └── merge.spec.js ├── bounce-in-down.js ├── bounce-in-left.js ├── bounce-in-right.js ├── bounce-in-up.js ├── bounce-in.js ├── bounce-out-down.js ├── bounce-out-left.js ├── bounce-out-right.js ├── bounce-out-up.js ├── bounce-out.js ├── bounce.js ├── fade-in-down-big.js ├── fade-in-down.js ├── fade-in-left-big.js ├── fade-in-left.js ├── fade-in-right-big.js ├── fade-in-right.js ├── fade-in-up-big.js ├── fade-in-up.js ├── fade-in.js ├── fade-out-down-big.js ├── fade-out-down.js ├── fade-out-left-big.js ├── fade-out-left.js ├── fade-out-right-big.js ├── fade-out-right.js ├── fade-out-up-big.js ├── fade-out-up.js ├── fade-out.js ├── flash.js ├── flip-in-x.js ├── flip-in-y.js ├── flip-out-x.js ├── flip-out-y.js ├── flip.js ├── head-shake.js ├── hinge.js ├── index.js ├── jello.js ├── light-speed-in.js ├── light-speed-out.js ├── merge.js ├── pulse.js ├── roll-in.js ├── roll-out.js ├── rotate-in-down-left.js ├── rotate-in-down-right.js ├── rotate-in-up-left.js ├── rotate-in-up-right.js ├── rotate-in.js ├── rotate-out-down-left.js ├── rotate-out-down-right.js ├── rotate-out-up-left.js ├── rotate-out-up-right.js ├── rotate-out.js ├── rubber-band.js ├── shake.js ├── slide-in-down.js ├── slide-in-left.js ├── slide-in-right.js ├── slide-in-up.js ├── slide-out-down.js ├── slide-out-left.js ├── slide-out-right.js ├── slide-out-up.js ├── swing.js ├── tada.js ├── types.js ├── utils.js ├── wobble.js ├── zoom-in-down.js ├── zoom-in-left.js ├── zoom-in-right.js ├── zoom-in-up.js ├── zoom-in.js ├── zoom-out-down.js ├── zoom-out-left.js ├── zoom-out-right.js ├── zoom-out-up.js └── zoom-out.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "react"], 3 | "plugins": [ 4 | "transform-object-rest-spread", 5 | "transform-export-extensions" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | libs 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "parser": "babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "es6": true, 6 | "node": true, 7 | "jest": true, 8 | }, 9 | "extends": [ 10 | "formidable/configurations/es6" 11 | ], 12 | "parserOptions": { 13 | "sourceType": "module" 14 | }, 15 | "plugins": [ 16 | "flowtype" 17 | ], 18 | "rules": { 19 | "no-magic-numbers": [ 20 | "off" 21 | ], 22 | "quotes": [ 23 | "error", 24 | "single" 25 | ], 26 | "max-params": [ 27 | "error", 28 | 4 29 | ] 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | /demo/.* 3 | /lib/.* 4 | /dist/.* 5 | /node_modules/.* 6 | 7 | 8 | [include] 9 | 10 | [libs] 11 | 12 | [options] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### SublimeText ### 2 | *.sublime-workspace 3 | 4 | ### OSX ### 5 | .DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear on external disk 14 | .Spotlight-V100 15 | .Trashes 16 | 17 | ### Windows ### 18 | # Windows image file caches 19 | Thumbs.db 20 | ehthumbs.db 21 | 22 | # Folder config file 23 | Desktop.ini 24 | 25 | # Recycle Bin used on file shares 26 | $RECYCLE.BIN/ 27 | 28 | # App specific 29 | 30 | coverage 31 | node_modules 32 | bower_components 33 | .tmp 34 | lib 35 | dist 36 | npm-debug.log* 37 | *.sublime-project 38 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | test 3 | demo 4 | Procfile 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Formidable Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: npm run demo 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Maintenance Status][maintenance-image]](#maintenance-status) 2 | 3 | # react-animations 4 | 5 | 6 | A collection of animations that can be used with any inline style library that supports using objects to define keyframe animations, such as Radium or Aphrodite. React-animations implements all animations from [animate.css](https://daneden.github.io/animate.css/). 7 | 8 | [Check out the interactive demo](http://react-animations.herokuapp.com/). 9 | 10 | [Explore component collection](https://bit.dev/formidablelabs/react-animations). 11 | 12 |

13 | 14 |

15 | 16 | ### Usage 17 | 18 | You can import each animation directly from the main package 19 | 20 | ```js 21 | import { fadeIn } from 'react-animations' 22 | ``` 23 | 24 | or you can import a specific animation directly 25 | 26 | ```js 27 | import fadeIn from 'react-animations/lib/fade-in' 28 | ``` 29 | 30 | 31 | ### Usage with [Radium](https://github.com/FormidableLabs/radium) 32 | 33 | ```js 34 | import React from 'react'; 35 | import { bounce } from 'react-animations'; 36 | import Radium, {StyleRoot} from 'radium'; 37 | 38 | const styles = { 39 | bounce: { 40 | animation: 'x 1s', 41 | animationName: Radium.keyframes(bounce, 'bounce') 42 | } 43 | } 44 | 45 | class Test extends React.Component { 46 | render() { 47 | 48 |
49 |
50 |
51 | } 52 | } 53 | 54 | ``` 55 | 56 | ### Usage with [Aphrodite](https://github.com/Khan/aphrodite) 57 | 58 | ```js 59 | import { bounce } from 'react-animations'; 60 | import { StyleSheet, css } from 'aphrodite'; 61 | 62 | const styles = StyleSheet.create({ 63 | bounce: { 64 | animationName: bounce, 65 | animationDuration: '1s' 66 | } 67 | }) 68 | ``` 69 | 70 | ### Usage with [JSS](https://github.com/cssinjs/react-jss) 71 | 72 | ```js 73 | import { bounce } from 'react-animations'; 74 | import jss from 'jss' 75 | import preset from 'jss-preset-default' 76 | 77 | jss.setup(preset()) 78 | 79 | const {classes} = jss.createStyleSheet({ 80 | '@keyframes bounce': bounce, 81 | bounce: { 82 | animationName: 'bounce', 83 | animationDuration: '1s', 84 | }, 85 | }).attach() 86 | ``` 87 | 88 | ### Usage with [`styled-components`](https://github.com/styled-components/styled-components) 89 | 90 | ```js 91 | import styled, { keyframes } from 'styled-components'; 92 | import { bounce } from 'react-animations'; 93 | 94 | const bounceAnimation = keyframes`${bounce}`; 95 | 96 | const BouncyDiv = styled.div` 97 | animation: 1s ${bounceAnimation}; 98 | `; 99 | ``` 100 | 101 | ### Usage with [`fela-js`](https://github.com/robinweser/fela) 102 | 103 | ```js 104 | import React from 'react'; 105 | import { render } from 'react-dom'; 106 | import { createRenderer } from 'fela'; 107 | import { createComponent, Provider } from 'react-fela'; 108 | import { bounce } from 'react-animations'; 109 | 110 | const mapStylesToProps = ({ background, height, width }, renderer) => ({ 111 | animationName: renderer.renderKeyframe(() => bounce, {}), 112 | animationDuration: '2s', 113 | background, 114 | height, 115 | width, 116 | }); 117 | 118 | const BouncingDiv = createComponent(mapStylesToProps, 'div'); 119 | 120 | render( 121 | 122 | 123 | , 124 | document.getElementById('root'), 125 | ); 126 | ``` 127 | 128 | ## Animations 129 | 130 | Below is a list of all available animations 131 | 132 | `bounceOut` 133 | 134 | `bounce` 135 | 136 | `bounceIn` 137 | 138 | `bounceInDown` 139 | 140 | `bounceInLeft` 141 | 142 | `bounceInRight` 143 | 144 | `bounceInUp` 145 | 146 | `bounceOutDown` 147 | 148 | `bounceOutLeft` 149 | 150 | `bounceOutRight` 151 | 152 | `bounceOutUp` 153 | 154 | `fadeIn` 155 | 156 | `fadeInDown` 157 | 158 | `fadeInDownBig` 159 | 160 | `fadeInLeft` 161 | 162 | `fadeInLeftBig` 163 | 164 | `fadeInRight` 165 | 166 | `fadeInRightBig` 167 | 168 | `fadeInUp` 169 | 170 | `fadeInUpBig` 171 | 172 | `fadeOut` 173 | 174 | `fadeOutDown` 175 | 176 | `fadeOutDownBig` 177 | 178 | `fadeOutLeft` 179 | 180 | `fadeOutLeftBig` 181 | 182 | `fadeOutRight` 183 | 184 | `fadeOutRightBig` 185 | 186 | `fadeOutUp` 187 | 188 | `fadeOutUpBig` 189 | 190 | `flash` 191 | 192 | `flip` 193 | 194 | `flipInX` 195 | 196 | `flipInY` 197 | 198 | `flipOutX` 199 | 200 | `flipOutY` 201 | 202 | `headShake` 203 | 204 | `hinge` 205 | 206 | `jello` 207 | 208 | `lightSpeedIn` 209 | 210 | `lightSpeedOut` 211 | 212 | `pulse` 213 | 214 | `rollIn` 215 | 216 | `rollOut` 217 | 218 | `rotateIn` 219 | 220 | `rotateInDownLeft` 221 | 222 | `rotateInDownRight` 223 | 224 | `rotateInUpLeft` 225 | 226 | `rotateInUpRight` 227 | 228 | `rotateOut` 229 | 230 | `rotateOutDownLeft` 231 | 232 | `rotateOutDownRight` 233 | 234 | `rotateOutUpLeft` 235 | 236 | `rotateOutUpRight` 237 | 238 | `rubberBand` 239 | 240 | `shake` 241 | 242 | `slideInDown` 243 | 244 | `slideInLeft` 245 | 246 | `slideInRight` 247 | 248 | `slideInUp` 249 | 250 | `slideOutDown` 251 | 252 | `slideOutLeft` 253 | 254 | `slideOutRight` 255 | 256 | `slideOutUp` 257 | 258 | `swing` 259 | 260 | `tada` 261 | 262 | `wobble` 263 | 264 | `zoomIn` 265 | 266 | `zoomInDown` 267 | 268 | `zoomInLeft` 269 | 270 | `zoomInRight` 271 | 272 | `zoomInUp` 273 | 274 | `zoomOut` 275 | 276 | `zoomOutDown` 277 | 278 | `zoomOutLeft` 279 | 280 | `zoomOutRight` 281 | 282 | `zoomOutUp` 283 | 284 | 285 | ## Merge 286 | 287 | react-animations also exports a `merge` function that takes two animations and returns a new animation that combines the transforms from both. This is experimental and wont work (well) with animations that have conflicting transforms, such as `fadeIn` and `fadeOut`. The merged animation can be used just like any of the imported animations. 288 | 289 | 290 | ```js 291 | 292 | import { merge, tada, flip } from 'react-animations'; 293 | const tadaFlip = merge(tada, flip); 294 | ``` 295 | 296 | ### Maintenance Status 297 | 298 | **Archived:** This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own! 299 | 300 | [maintenance-image]: https://img.shields.io/badge/maintenance-archived-red.svg 301 | -------------------------------------------------------------------------------- /demo/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "es6": true 5 | }, 6 | "extends": [ 7 | "formidable/configurations/es6" 8 | ], 9 | "parserOptions": { 10 | "ecmaFeatures": { 11 | "experimentalObjectRestSpread": true, 12 | "jsx": true 13 | }, 14 | "sourceType": "module" 15 | }, 16 | "plugins": [ 17 | "react" 18 | ], 19 | "rules": { 20 | "indent": [ 21 | "error", 22 | 2 23 | ], 24 | "linebreak-style": [ 25 | "error", 26 | "unix" 27 | ], 28 | "quotes": [ 29 | "error", 30 | "single" 31 | ], 32 | "semi": [ 33 | "error", 34 | "always" 35 | ] 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /demo/app.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import Radium, { Style, StyleRoot } from 'radium'; 4 | import * as animations from '../lib'; 5 | 6 | import Demo from './demo'; 7 | 8 | const styles = { 9 | global: { 10 | textAlign: 'center', 11 | paddingTop: 200, 12 | body: { 13 | backgroundColor: '#e7e5e3', 14 | fontFamily: 'Whitney SSm A, Whitney SSm B, Helvetica Neue, Helvetica, Arial, sans-serif', 15 | lineHeight: 1.5, 16 | margin: 0, 17 | transform: 'translate3d(0, 0, 0)', 18 | }, 19 | p: { 20 | margin: 0, 21 | color: '#242121' 22 | }, 23 | select: { 24 | border: 'none', 25 | height: 35, 26 | fontSize: 15, 27 | fontFamily: 'inherit', 28 | width: 155, 29 | fontWeight: 'bold', 30 | }, 31 | input: { 32 | height: 35, 33 | width: 50, 34 | border: 'none', 35 | padding: '0px 5px', 36 | borderRadius: 6, 37 | fontFamily: 'inherit' 38 | }, 39 | button: { 40 | backgroundColor: 'white', 41 | outline: 'none', 42 | height: 35, 43 | border: 'none', 44 | padding: '0px 10px', 45 | borderRadius: 6, 46 | fontFamily: 'inherit' 47 | }, 48 | label: { 49 | color: '#242121', 50 | position: 'absolute', 51 | bottom: 0, 52 | fontSize: 10, 53 | }, 54 | }, 55 | container: { 56 | position: 'relative', 57 | margin: 15, 58 | height: 60, 59 | display: 'inline-block', 60 | }, 61 | swing: { 62 | transformOrigin: 'top center' 63 | }, 64 | flip: { 65 | backfaceVisibilty: 'visible', 66 | }, 67 | }; 68 | 69 | const animationNames = []; 70 | 71 | for (let key in animations) { 72 | if ( 73 | key === 'global' || 74 | key === 'merge' || 75 | key === 'container' 76 | ) { 77 | continue; 78 | } 79 | animationNames.push(key); 80 | const animation = animations[key]; 81 | styles[key] = { 82 | ...styles[key], 83 | animation: 'x', 84 | animationName: Radium.keyframes(animation, key), 85 | }; 86 | } 87 | 88 | class App extends React.Component { 89 | 90 | constructor() { 91 | super(); 92 | this.state = { 93 | animation: 'bounce', 94 | library: 'Radium', 95 | }; 96 | this.duration = 1; 97 | this.selectAnimation = this.selectAnimation.bind(this); 98 | this.onDurationChange = this.onDurationChange.bind(this); 99 | this.triggerAnimation = this.triggerAnimation.bind(this); 100 | } 101 | 102 | selectAnimation({ target }) { 103 | this.setState({ animation: target.value }); 104 | } 105 | 106 | onDurationChange({ target }) { 107 | // Track duration outside of state, as we don't 108 | // want duration changes to trigger a render. 109 | this.duration = parseFloat(target.value); 110 | } 111 | 112 | triggerAnimation() { 113 | const { animation } = this.state; 114 | this.setState({ animation: '' }, () => { 115 | this.setState({ animation }); 116 | }); 117 | } 118 | 119 | render() { 120 | const { animation } = this.state; 121 | return ( 122 | 123 |
124 |