File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -22,18 +22,11 @@ class Header extends React.Component {
2222 this . state = {
2323 mobileOpen : false
2424 } ;
25- this . handleDrawerToggle = this . handleDrawerToggle . bind ( this ) ;
26- this . headerColorChange = this . headerColorChange . bind ( this ) ;
2725 }
28- handleDrawerToggle ( ) {
26+ handleDrawerToggle = ( ) => {
2927 this . setState ( { mobileOpen : ! this . state . mobileOpen } ) ;
3028 }
31- componentDidMount ( ) {
32- if ( this . props . changeColorOnScroll ) {
33- window . addEventListener ( "scroll" , this . headerColorChange ) ;
34- }
35- }
36- headerColorChange ( ) {
29+ headerColorChange = ( ) => {
3730 const { classes, color, changeColorOnScroll } = this . props ;
3831 const windowsScrollTop = window . pageYOffset ;
3932 if ( windowsScrollTop > changeColorOnScroll . height ) {
@@ -52,6 +45,11 @@ class Header extends React.Component {
5245 . classList . remove ( classes [ changeColorOnScroll . color ] ) ;
5346 }
5447 }
48+ componentDidMount ( ) {
49+ if ( this . props . changeColorOnScroll ) {
50+ window . addEventListener ( "scroll" , this . headerColorChange ) ;
51+ }
52+ }
5553 componentWillUnmount ( ) {
5654 if ( this . props . changeColorOnScroll ) {
5755 window . removeEventListener ( "scroll" , this . headerColorChange ) ;
@@ -100,7 +98,7 @@ class Header extends React.Component {
10098 </ IconButton >
10199 </ Hidden >
102100 </ Toolbar >
103- < Hidden mdUp implementation = "css " >
101+ < Hidden mdUp implementation = "js " >
104102 < Drawer
105103 variant = "temporary"
106104 anchor = { "right" }
You can’t perform that action at this time.
0 commit comments