1 | [![Cover][cover-img]][cover-url]
|
2 |
|
3 | # react-anime
|
4 |
|
5 | [![Npm Package][npm-img]][npm-url]
|
6 | [![Travis CI][travis-img]][travis-url]
|
7 | [![License][license-img]][license-url]
|
8 | [![Codecov][codecov-img]][codecov-url]
|
9 | [![Dependency Status][david-img]][david-url]
|
10 | [![devDependency Status][david-dev-img]][david-dev-url]
|
11 | [![License][license-img]][license-url]
|
12 |
|
13 | react-anime was written in an effort to make animations easier to work with. We
|
14 | made this possible by wrapping the awesome flexible yet lightweight JavaScript
|
15 | animation library, [anime](https://github.com/juliangarnier/anime) in a react
|
16 | component. Simply pass some props and your awesome animations come to life.
|
17 |
|
18 | We wrote this library because [react-motion](https://github.com/chenglou/react-motion) could get really complex really really fast when animating several things and trying to coordinate
|
19 | with the animations. Also it wasn't nice to see large portions of some component code filled with callbacks. react-motion nonetheless is an awesome animation library!
|
20 |
|
21 | ## Install
|
22 |
|
23 | ```bash
|
24 | npm i react-anime -S
|
25 | ```
|
26 |
|
27 | ## Usage
|
28 |
|
29 | ```js
|
30 | import React from 'react';
|
31 | import Anime from 'react-anime';
|
32 |
|
33 | let root = (props, state) => (
|
34 | <Anime easing="easeOutElastic"
|
35 | duration={1000}
|
36 | direction="alternate"
|
37 | loop={true}
|
38 | delay={(el, index) => index * 240}
|
39 | translateX='13rem'
|
40 | scale={[.75, .9]}>
|
41 | <div className="blue"/>
|
42 | <div className="green"/>
|
43 | <div className="red"/>
|
44 | </Anime>
|
45 | );
|
46 | ```
|
47 |
|
48 | ## API
|
49 |
|
50 | The API is based off [anime.js](https://github.com/juliangarnier/anime) documentation. TypeScript/Flow definitions are included so refer to those if you have any other questions.
|
51 |
|
52 | | Prop | Type |
|
53 | |:-----------------:|:---------------|
|
54 | | `delay` | `(el: Element, index?: number, len?: number) => number | number` |
|
55 | | `duration` | `TimingValue ( above )` |
|
56 | | `autoplay` | `boolean` |
|
57 | | `loop` | `number | boolean` |
|
58 | | `direction` | `'normal' | 'reverse' | 'alternate'` |
|
59 | | `easing` | `'easeInSine' | 'easeOutSine' | 'easeInOutSine' | 'easeInCirc' | 'easeOutCirc' | 'easeInOutCirc' | 'easeInElastic' | 'easeOutElastic' | 'easeInOutElastic' | 'easeInBack' | 'easeOutBack' | 'easeInOutBack' | 'easeInBounce' | 'easeOutBounce' | 'easeInOutBounce' | 'easeInQuad' | 'easeOutQuad' | 'easeInOutQuad' | 'easeInCubic' | 'easeOutCubic' | 'easeInOutCubic' | 'easeInQuart' | 'easeOutQuart' | 'easeInOutQuart' | 'easeInQuint' | 'easeOutQuint' | 'easeInOutQuint' | 'easeInExpo' | 'easeOutExpo' | 'easeInOutExpo' | 'linear'` |
|
60 | |`elasticity` | `number` |
|
61 | | `round` | `number | boolean` |
|
62 | | `begin` | `(anime: AnimeInstance) => void` |
|
63 | | `update` | `(anime: AnimeInstance) => void` |
|
64 | | `complete` | `(anime: AnimeInstance) => void` |
|
65 | | `[index: string]` | `string | number | (string | number)[2] | ((el: Element, index?: number) => string | number) | { value: string | number, delay: TimingValues, duration?: TimingValues, easing?: Easing }` |
|
66 |
|
67 | **Note** the last prop type, any other props can be used by anime, from CSS attributes to SVG attributes, you name it. :)
|
68 |
|
69 | ### Transforms
|
70 |
|
71 | | Prop | Type |
|
72 | |:-----------------:|:----------------|
|
73 | | `translateX` | `AnimationProp (Above)` |
|
74 | | `translateY` | `AnimationProp` |
|
75 | | `rotate` | `AnimationProp` |
|
76 | | `scale` | `AnimationProp` |
|
77 | | `scaleX` | `AnimationProp` |
|
78 | | `scaleY` | `AnimationProp` |
|
79 |
|
80 | ### SVGs
|
81 |
|
82 | | Prop | Type |
|
83 | |:-----------------:|:---------------|
|
84 | | `d` | `AnimationProp` |
|
85 | | `rx` | `AnimationProp` |
|
86 | | `transform` | `AnimationProp` |
|
87 | | `scale` | `AnimationProp` |
|
88 | | `scaleX` | `AnimationProp` |
|
89 | | `scaleY` | `AnimationProp` |
|
90 |
|
91 | ### DOM
|
92 |
|
93 | | Prop | Type |
|
94 | |:-----------------:|:----------------|
|
95 | | `value` | `AnimationProp` |
|
96 | | `volume` | `AnimationProp` |
|
97 |
|
98 | And more.
|
99 |
|
100 | ## Contributing
|
101 |
|
102 | To contribute make sure you have `node v6.0.0+` and `npm v3.8.0+`
|
103 |
|
104 | ## Project Scripts
|
105 |
|
106 | ```bash
|
107 | # Create Development build of library
|
108 | npm run build:develop
|
109 |
|
110 | # Create Production build of library
|
111 | npm run build:production
|
112 |
|
113 | # Create both Production & Development build before finalizing pull request
|
114 | npm run build:publish
|
115 |
|
116 | # Run Tests
|
117 | npm run test
|
118 |
|
119 | # Watch Tests
|
120 | npm run test:watch
|
121 |
|
122 | # Run Tests and pass coverage to codecov
|
123 | npm run coverage
|
124 | ```
|
125 |
|
126 | [cover-img]: assets/cover.gif
|
127 | [cover-url]: http://codepen.io/alaingalvan/details/EgjbKP/
|
128 | [license-img]: http://img.shields.io/:license-mit-blue.svg?style=flat-square
|
129 | [license-url]: https://opensource.org/licenses/MIT
|
130 | [david-url]: https://david-dm.org/alaingalvan/react-anime
|
131 | [david-img]: https://david-dm.org/alaingalvan/react-anime.svg?style=flat-square
|
132 | [david-dev-url]: https://david-dm.org/alaingalvan/react-anime#info=devDependencies
|
133 | [david-dev-img]: https://david-dm.org/alaingalvan/react-anime/dev-status.svg?style=flat-square
|
134 | [travis-img]: https://img.shields.io/travis/stelatech/react-anime.svg?style=flat-square
|
135 | [travis-url]:https://travis-ci.org/alaingalvan/react-anime
|
136 | [codecov-img]:https://img.shields.io/codecov/c/github/alaingalvan/react-anime.svg?style=flat-square
|
137 | [codecov-url]: https://codecov.io/gh/alaingalvan/react-anime
|
138 | [npm-img]: https://img.shields.io/npm/v/react-anime.svg?style=flat-square
|
139 | [npm-url]: http://npm.im/react-anime
|
140 | [npm-download-img]: https://img.shields.io/npm/dm/react-anime.svg?style=flat-square
|