Skip to content

Commit

Permalink
[Snackbar] Fix animation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejunges committed May 22, 2016
1 parent 5b1e341 commit 9ee3306
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default class SnackbarExampleSimple extends React.Component {
}

handleTouchTap = (message) => {

this.setState({
open: true,
message: message,
Expand Down
7 changes: 4 additions & 3 deletions src/Snackbar/Snackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import transitions from '../styles/transitions';
import ClickAwayListener from '../internal/ClickAwayListener';
import SnackbarBody from './SnackbarBody';

function getStyles(props, context, state) {
function getStyles(props, context, state, component) {
const {
muiTheme: {
baseTheme: {
Expand All @@ -16,6 +16,7 @@ function getStyles(props, context, state) {
} = context;

const {open} = state;
const isMultiline = component.messageElement && component.messageElement.offsetHeight > 20;

const styles = {
root: {
Expand All @@ -28,7 +29,7 @@ function getStyles(props, context, state) {
visibility: open ? 'visible' : 'hidden',
transform: open ?
'translate3d(0, 0, 0)' :
`translate3d(0, ${desktopSubheaderHeight}px, 0)`,
`translate3d(0, ${isMultiline ? 80 : desktopSubheaderHeight}px, 0)`,
transition: `${transitions.easeOut('400ms', 'transform')}, ${
transitions.easeOut('400ms', 'visibility')}`,
},
Expand Down Expand Up @@ -208,7 +209,7 @@ class Snackbar extends Component {
} = this.state;

const {prepareStyles} = this.context.muiTheme;
const styles = getStyles(this.props, this.context, this.state);
const styles = getStyles(this.props, this.context, this.state, this);

return (
<ClickAwayListener onClickAway={open && this.componentClickAway}>
Expand Down

0 comments on commit 9ee3306

Please sign in to comment.