Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu committed Jun 18, 2019
1 parent a9158ab commit 3a1fb56
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,11 @@ class Header extends React.Component {
this.state = {
mobileOpen: false
};
this.handleDrawerToggle = this.handleDrawerToggle.bind(this);
this.headerColorChange = this.headerColorChange.bind(this);
}
handleDrawerToggle() {
handleDrawerToggle = () => {
this.setState({ mobileOpen: !this.state.mobileOpen });
}
componentDidMount() {
if (this.props.changeColorOnScroll) {
window.addEventListener("scroll", this.headerColorChange);
}
}
headerColorChange() {
headerColorChange = () => {
const { classes, color, changeColorOnScroll } = this.props;
const windowsScrollTop = window.pageYOffset;
if (windowsScrollTop > changeColorOnScroll.height) {
Expand All @@ -52,6 +45,11 @@ class Header extends React.Component {
.classList.remove(classes[changeColorOnScroll.color]);
}
}
componentDidMount() {
if (this.props.changeColorOnScroll) {
window.addEventListener("scroll", this.headerColorChange);
}
}
componentWillUnmount() {
if (this.props.changeColorOnScroll) {
window.removeEventListener("scroll", this.headerColorChange);
Expand Down Expand Up @@ -100,7 +98,7 @@ class Header extends React.Component {
</IconButton>
</Hidden>
</Toolbar>
<Hidden mdUp implementation="css">
<Hidden mdUp implementation="js">
<Drawer
variant="temporary"
anchor={"right"}
Expand Down

0 comments on commit 3a1fb56

Please sign in to comment.