An open API service indexing awesome lists of open source software.

https://github.com/aitoroses/react-animation-engine

Extract famo.us transitionable capabilities in 14kb for react. Mixin to transition between state values.
https://github.com/aitoroses/react-animation-engine

Last synced: about 2 months ago
JSON representation

Extract famo.us transitionable capabilities in 14kb for react. Mixin to transition between state values.

Awesome Lists containing this project

README

          

# react-animation-engine
Extract famous transitionable capabilities in 10kb. Mixin to transition between state values.

![Spring animation](http://s8.postimg.org/w9knnfj6d/springs.gif)

# Install

```
npm install react-animation-engine
```

# Usage
```jsx

import {TransitionableMixin, Easing} from 'react-animation-engine';

var TestComponent = React.createClass({

/**
* Define transitionable properties
*/
mixins: [TransitionableMixin(["width", "height"])],

/**
* Return initial values for the transitionables
*/
getInitialState() {
return {
width: 200,
height: 50
}
},

/**
* Animate using Easing functions
*/
handleButtonClick() {
this.width = {
value: document.body.clientWidth / 2,
duration: 5000
};
this.height = {
value: document.body.clientHeight / 2,
duration: 2000,
curve: Easing.outCirc
};
},

/**
* Animate using Springs
*/
handleClick() {
// Halt the ongoing animation
this.handleStop();

// Toggle the status
var toggle = !!this.state.toggle;

// Animate
this.width = {
value: toggle ? 400: 100,
method: "spring",
dampingRatio: 0.2,
period: 1000
};
this.height = {
value: toggle ? 300: 200,
method: "spring",
dampingRatio: 0.2,
period: 500
};

// Store the state
this.setState({
toggle: !toggle
})
},

/**
* Handle transitionable stop
*/
handleStop() {
this.halt();
},

/**
* Render method
*/
render() {
return (


click me
Stop


)
}
});

/**
* Render component into body
*/
React.render(, document.body);
```