Skip to content

Commit

Permalink
Merge pull request #1390 from MetalMatze/feature/snackbar-events
Browse files Browse the repository at this point in the history
Add snackbar callbacks for onShow and onDismiss with documentation
  • Loading branch information
hai-cea committed Aug 13, 2015
2 parents 538979a + 78de37d commit f17eeb8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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 @@ -75,6 +75,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 @@ -93,7 +103,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

0 comments on commit f17eeb8

Please sign in to comment.