Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snackbar callbacks for onShow and onDismiss with documentation #1390

Merged
merged 1 commit into from
Aug 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/src/app/components/pages/components/snackbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ class SnackbarPage extends React.Component {
name: 'onActionTouchTap',
header: 'function(e)',
desc: 'Fired when the action button is touchtapped.'
},
{
name: 'onDismiss',
header: 'function()',
desc: 'Fired when the snackbar is dismissed.'
},
{
name: 'onShow',
header: 'function()',
desc: 'Fired when the snackbar is shown.'
}
]
}
Expand All @@ -104,7 +114,7 @@ class SnackbarPage extends React.Component {
<br />

<TextField
floatingLabelText="Auto Hide Duration"
floatingLabelText="Auto Hide Duration in ms"
value={this.state.autoHideDuration}
onChange={this._updateAutoHideDuration} />

Expand Down
4 changes: 4 additions & 0 deletions src/snackbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const Snackbar = React.createClass({
action: React.PropTypes.string,
autoHideDuration: React.PropTypes.number,
onActionTouchTap: React.PropTypes.func,
onShow: React.PropTypes.func,
onDismiss: React.PropTypes.func,
openOnMount: React.PropTypes.bool,
},

Expand Down Expand Up @@ -151,11 +153,13 @@ const Snackbar = React.createClass({

show() {
this.setState({ open: true });
if (this.props.onShow) this.props.onShow();
},

dismiss() {
this._clearAutoHideTimer();
this.setState({ open: false });
if (this.props.onDismiss) this.props.onDismiss();
},

_clearAutoHideTimer() {
Expand Down