Last active
August 29, 2015 13:57
-
-
Save pleasetrythisathome/9648154 to your computer and use it in GitHub Desktop.
react.animate example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var component = React.createClass({ | |
mixins: [React.Animate], | |
getInitialState: function() { | |
return { | |
width: 100 | |
}; | |
}, | |
render: function() { | |
var heightBounds = [50, 100]; | |
return React.DOM.div({ | |
style: { | |
width: this.state.width, | |
height: Math.min(heightBounds[1], Math.max(heightBounds[0], this.state.width / 2)) | |
}, | |
onClick: this.randomSize | |
}); | |
}, | |
randomSize: function() { | |
this.animate({ | |
width: _.random(20, 300) | |
}, 500, function() { | |
console.log("random size reached!"); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment