Skip to content

Commit

Permalink
add option to go back to normal state after success callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour committed May 6, 2015
1 parent 222f435 commit cb3e7d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Put the button in the loading state.

Put the button in the normal state.

##### success([callback])
##### success([callback, goBackToNormal])

Put the button in the success state. Call the callback or the onSuccess prop when going back to the normal state.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-progress-button",
"version": "0.1.7",
"version": "0.1.8",
"description": "Simple react.js component for a inline progress indicator",
"main": "react-progress-button.js",
"dependencies": {
Expand Down
6 changes: 4 additions & 2 deletions react-progress-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@
this.setState({currentState: ''});
},

success: function(callback) {
success: function(callback, remove) {
this.setState({currentState: 'success'});
this._timeout = setTimeout(function() {
callback = callback || this.props.onSuccess;
if (callback && typeof callback === "function") {
callback();
if (remove) { this.setState({currentState: ''}); }
} else {
this.setState({currentState: ''});
}
this.setState({currentState: ''});
}.bind(this), this.props.durationSuccess);
},

Expand Down

0 comments on commit cb3e7d0

Please sign in to comment.