Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react bootstrap hide toggle menu when scrolling down

  import React, { Component } from 'react';

   class App extends Component {

   constructor(props) {
    super(props);

      this.state = {  scrollBackground: 'nav-bg' };
      this.handleScroll = this.handleScroll.bind(this);
   }


   handleScroll(){
      this.setState ({
         scrollBackground: !this.state.scrollBackground
       })
    }

 render() {
 const scrollBg = this.scrollBackground ? 'nav-bg scrolling' : 'nav-bg';

 return (
   <div>

       <Navbar inverse toggleable className={this.state.scrollBackground} 
                                  onScroll={this.handleScroll}>
        ...
      </Navbar>

    </div>
   );
  }
}

export default App;
Comment

PREVIOUS NEXT
Code Example
Javascript :: useLocation for query params 
Javascript :: nodejs sequelize find 
Javascript :: mui icons 
Javascript :: remove last character of string in javascript 
Javascript :: moment js 
Javascript :: React social login button 
Javascript :: js random number array 
Javascript :: v- v-bind : 
Javascript :: TypeError: path must be absolute or specify root to res.sendFile 
Javascript :: javascript execute function after async 
Javascript :: uirouter 
Javascript :: how can i do metaname csrf token attrcontent in vanilla javascrip 
Javascript :: hincrby nodejs 
Javascript :: floor html 
Javascript :: react hook usestate 
Javascript :: what does useref do react 
Javascript :: gettwofactorauthenticationuserasync returns null 
Javascript :: react router dom default params 
Javascript :: how to add all files in a director to an array in javascript 
Javascript :: jquery autocomplete search 
Javascript :: push element in array javascript 
Javascript :: is missing in props validationeslintreact/prop-types 
Javascript :: sending json data uing fetch is empty 
Javascript :: express-session deprecated undefined resave option; provide resave option index.js:17:9 
Javascript :: lodash uniqby 
Javascript :: check javascript object not array and not null 
Javascript :: juqey off click 
Javascript :: search filter with react native on flatlist 
Javascript :: jqerrt get all img alt from string 
Javascript :: jquery-3.5.0.min.js 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =