Created
August 2, 2014 17:03
-
-
Save elierotenberg/b1c8662d2b1eeae0df97 to your computer and use it in GitHub Desktop.
SpinWheel.jsx
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
/** @jsx React.DOM */ | |
var React = require("react"); | |
var AnimateMixin = require("react-animate"); | |
var fromCSS = require("react-css").fromCSS; | |
var from = fromCSS("{" + | |
"transform: rotate(0deg);" + | |
"background-color: blue;" + | |
"margin: 50px;" + | |
"width: 200px;" + | |
"}"); | |
var to = fromCSS("{" + | |
"transform: rotate(359.9deg);" + | |
"background-color: blue;" + | |
"margin: 50px;" + | |
"width: 200px;" + | |
"}"); | |
var SpinWheel = React.createClass({ | |
mixins: [AnimateMixin], | |
getInitialState: function getInitialState() { | |
return { | |
spinning: false, | |
}; | |
}, | |
spin: function spin() { | |
this.animate("spinning", from, to, "linear", 5000, this.spin); | |
this.setState({ | |
spinning: true, | |
}); | |
}, | |
render: function render() { | |
return ( | |
<div> | |
<a onClick={this.spin}>Click to spin !</a> | |
{ this.state.spinning ? ( | |
<div style={this.getAnimatedStyle("spinning")}>Spin to win</div> | |
) : null } | |
</div> | |
); | |
}, | |
}); | |
module.exports = SpinWheel; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment