Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>	


<!--Chainng Text -->
<!--Chainng Text -->
<!--Chainng Text -->

<div class="textchange">Start</div>

<!-- MAIN SITE -->   
<!-- MAIN SITE --> 
<!-- MAIN SITE --> 

<div id="container">

  <!-- SECTION ONE START-->
  <div class="section one"> 
    <div class="marker" id="middle"></div>
  </div><!-- SECTION ONE END --> 


  <!-- SECTION TWO START-->
  <div class="section two">
    <div class="marker" id="end"></div>
    <button class="active-btn" onclick="toggleNav('sidenav1')"></button> 
    <div class="parallax-content"></div> 
  </div> <!-- SECTION TWO END --> 

  <div class="section three"></div>
  <div class="section four"></div>
  <div class="section five"></div>
  <div class="section six"></div>
</div>
	
	
<!-- JavaScript -->	
<!-- JavaScript -->	
<!-- JavaScript -->	

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/ScrollTrigger.min.js"></script>
<script src="script.js"></script> 
	
</body>
              
            
!

CSS

              
                @charset "UTF-8";
/* CSS Document */


html,body{
  padding:0;
  margin:0;
  overscroll-behavior-y: none;
  overscroll-behavior-x: none;
}
body {
  overflow-x: hidden;
  background: #000;

}

/* / HORIZONTAL SCROLL / */

#container {
  background-color:grey;
  display:flex;
  flex-wrap:wrap;
  flex-direction:column;
  height:100vh;
}

.section{
  height:100%;
  display:flex;
}


/* / SECTIONS /*/


.one{
  width:1920px;
  background: linear-gradient(to top, #051937, #203168, #48499a, #7b5fcc, #b673fc);
}

.two{
  width:1920px;
  
}

.parallax-content {
  background-image: url('https://images.unsplash.com/Ys-DBJeX0nE.JPG?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2670&q=80');
  position: relative;
  background-position: center;
  background-repeat: no-repeat;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.three{
  width:1920px;
  background: linear-gradient(to top, #051937, #203168, #48499a, #7b5fcc, #b673fc);

}

.four{
  width:1920px;
  background: linear-gradient(to top, #b673fc, #7b5fcc, #48499a, #203168, #051937);
}

.five{
  width:1920px;
  background: linear-gradient(to top, #051937, #203168, #48499a, #7b5fcc, #b673fc);
}

.six{
  width:1920px;
  background: linear-gradient(to top, #b673fc, #7b5fcc, #48499a, #203168, #051937);
  }

/* //CHANGING ELEMENT  */


.textchange {
  position: fixed;
  z-index:  99;
  top: 30px;
  left: 50%; 
  -ms-transform: translateX(-50%);
  transform: translateX(-50%);
  font-family: rubik;
  font-weight: 700;
  font-size: 40px;
  color:  #fff;

}

.marker {
  position: relative;
  top: 10px;
  opacity: 0;

}

/* MARKER POSITIONS */

#middle {left: 100%;}
#end {left: 100%;}

/* / BUTTONS / */

.active-btn {
    width: 250px;
    height: 50px;
    border: none;
    outline: none;
    color: #111;
    background: #fff;
    cursor: pointer;
    position: absolute;
    top: 40%;
    left: 50%;
    z-index: 0;
  padding: 0;
  margin: 0;
}



              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger)


/* HORIZONTAL */  
/* HORIZONTAL */ 
/* HORIZONTAL */

let formats = document.querySelectorAll(".section");

let horizontalScroll = gsap.to(formats, {
  xPercent: -100 * (formats.length - 1),
  ease: "none",
  scrollTrigger: {
    trigger: "#container",
    pin: true,
    scrub: 1,
    end: () => "+=" + document.querySelector("#container").offsetWidth
  }
 });

/* MARKER CHANGE */  
/* MARKER CHANGE */ 
/* MARKER CHANGE */ 

let text = document.querySelector(".textchange");
ScrollTrigger.create({
  containerAnimation: horizontalScroll,
  trigger: "#middle",
  start: "left center",
  onEnter: self => text.innerText = "Middle",
  onLeaveBack: self => text.innerText = "Start"
});

ScrollTrigger.create({
  containerAnimation: horizontalScroll,
  trigger: "#end",
  start: "left center",
  onEnter: self => text.innerText = "End",
  onLeaveBack: self => text.innerText = "Middle"
});


/* BUTTON ANIMATION */  
/* BUTTON ANIMATION */ 
/* BUTTON ANIMATION */ 

var buttons = gsap.utils.toArray('.active-btn');

buttons.forEach((button) => {

gsap.from(button,{
  y: 50,
  duration: 0.6,
  opacity: 0,
  scrollTrigger: {
    containerAnimation: horizontalScroll,
    trigger: button,
    start: "centre 80%",
    end: "centre 20%",
    /* markers: true, */ 
    toggleActions: "play reverse play reverse",
  }
});
  
})

/* BACKROUND PARALAX TEST */  
/* BACKROUND PARALAX TEST */ 
/* BACKROUND PARALAX TEST */ 



/* PREVENT SAFARI OVERSCROLL */  
/* PREVENT SAFARI OVERSCROLL */  
/* PREVENT SAFARI OVERSCROLL */  


stopOverscroll("#viewport");
function stopOverscroll(element) {
  element = gsap.utils.toArray(element)[0];
  element.style.scrollBehavior = "none";
  if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
    let kill = e => {
      if (element.scrollTop <= 0) {
        element.scrollTop = 1;
        e.preventDefault();
      } else if (element.scrollTop >= element.scrollHeight - element.clientHeight) {
        element.scrollTop = element.scrollHeight - element.clientHeight - 1;
        e.preventDefault();
      }
    }
    element.addEventListener("wheel", kill, {passive: false});
    element.addEventListener("touchmove", kill, {passive: false});
  }
}

              
            
!
999px

Console