Skip to content

Instantly share code, notes, and snippets.

@morukutsu
Created July 8, 2015 00:36
Show Gist options
  • Save morukutsu/c3b01e7946104f4d87af to your computer and use it in GitHub Desktop.
Save morukutsu/c3b01e7946104f4d87af to your computer and use it in GitHub Desktop.
var React = require('react-native');
var tweenState = require('react-tween-state');
var {
View,
Text
} = React;
var Test = React.createClass({
mixins: [tweenState.Mixin],
getInitialState: function() {
return {counter: 0};
},
componentDidMount: function() {
this.count();
},
count: function() {
// This is the API you'll probably use 90% of the time.
this.tweenState('counter', {
duration: 500,
beginValue: 0,
endValue: this.state.counter + 500,
onEnd: this.count
});
console.log("Called");
},
render: function() {
return (
<View style={{justifyContent: 'center', alignItems: 'center', flex: 1}}>
<Text>easeOutQuad on a counter! {Math.round(this.getTweeningValue('counter'))}</Text>
</View>
);
}
});
module.exports = Test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment