Skip to content

Instantly share code, notes, and snippets.

@ustun
Created June 5, 2014 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ustun/c90d3d57bfe2033caa4c to your computer and use it in GitHub Desktop.
Save ustun/c90d3d57bfe2033caa4c to your computer and use it in GitHub Desktop.
react spinning mixin
// include http://fgnass.github.io/spin.js/jquery.spin.js first
var SpinningMixin = {
componentWillUpdate: function (nextProps, nextState) {
if (this.state.inProgress && !nextState.inProgress) {
this.stopSpinning();
}
if (!this.state.inProgress && nextState.inProgress) {
this.startSpinning();
}
},
startSpinning: function () {
$(this.getDOMNode()).spin(true);
},
stopSpinning: function () {
$(this.getDOMNode()).spin(false);
}
};
module.exports = SpinningMixin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment