React Transition Component
React.js component that will apply transitions on any prop change. Was created to be used on drawing SVG charts with D3, but can be used for anything.
Check the live demo.
Usage
Here is an example usage:
<ReactTransition component="div" ease="bounce" duration="500" style= left: left />
The ReactTransition
component will actualy render a div
, and it will apply the bounce
ease function with a duration of 500
milisseconds on any componentWillReceiveProps of the style
property.
Install
Install with NPM:
npm install react-transition
It also is available as an UMD. Having support for AMD, CommonJS and globals, which can be installed through Bower:
bower install react-transition
Or simply dowloading the dist/react-transition.js distribution file and add as a script tag in your HTML (it will expose a ReactTransition
global variable) allongsite with its depencencies:
Easing functions
Check D3's documentation to see the available easing function. But some examples are:
- linear - the identity function, t.
- poly(k) - raises t to the specified power k (e.g., 3).
- quad - equivalent to poly(2).
- cubic - equivalent to poly(3).
- sin - applies the trigonometric function sin.
- exp - raises 2 to a power based on t.
- circle - the quarter circle.
- elastic(a, p) - simulates an elastic band;
- back(s) - simulates backing into a parking space.
- bounce - simulates a bouncy collision.
Author
Similar work
You can check @chenglou's approach to animation using mixins: react-tween-state.