Advertisement
Guest User

Handle Scroll

a guest
Dec 19th, 2017
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         handleScrollWithBar = (e) => {
  2.             if(e.target.scrollHeight > e.target.offsetHeight){
  3.                 if(e.target.offsetHeight + e.target.scrollTop == e.target.scrollHeight){
  4.                     let scrolled = update(this.state.scrolled, {$merge: {isScrolled: false }});
  5.                     this.setState({scrolled});
  6.                     this.nextSection();
  7.                 }
  8.             }
  9.         };
  10.  
  11.         nextSection = () => {
  12.         if(!this.state.scrolled.isScrolled){
  13.             var nxtSection = this.state.heightScreen + 100;
  14.             this.setState({ heightScreen: nxtSection });
  15.             var newCss = document.createElement("style");
  16.             newCss.type = "text/css";
  17.             newCss.innerHTML = ".page-home { transform: translate3d(0px, -"+nxtSection+"vh, 0px); }";
  18.             document.body.appendChild(newCss);
  19.         }
  20.     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement