Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div class="slides-wrapper">
<section class="panel">
	  <div class="panel-content"><h1>Section 1</h1>
	    <img class="image" src='https://images.unsplash.com/photo-1620321023374-d1a68fbc720d?crop=entropy&cs=srgb&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYyMjk3MzA3Mg&ixlib=rb-1.2.1&q=85' alt=''>
	  </div>
</section>
<section class="panel section-2">
  <div class="panel-content height"><div class="dd"><h1>Section 2</h1>
    <p>This section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes inThis section is supposed to be long and scrollable within before the next slide comes in</p>
  </div></div>
</section>
<section class="panel section-3">
	  <div class="panel-content"><h1>Section 3</h1></div>
</section>
<section class="panel">
	  <div class="panel-content"><h1>Section 4</h1></div>
</section>
</div>
<div class="nav">
  <div class="logo">
    Nav
  </div>
  <div class="nav-links">
    <p>Link</p>
    <p>Link</p>
    <p>Link</p>
  </div>
</div>

              
            
!

CSS

              
                html, body {
  margin: 0;
  height: 100%;
  background:#000;
  color:#141414;
  -webkit-overflow-scrolling: touch;
  overflow-scrolling: touch;
  font-family: "Helvetica", sans-serif, Arial;
}

.nav{
  width:100%;
  height:60px;
  position:fixed;
  top:0;
  z-index:999;
  display:flex;
  color:#fff;
  background:#000;
  justify-content:space-between;
}

.nav-links {
  display:flex;
}

.slides-wrapper {
  margin-top:63px;
}

.image {
  width:50%;
  margin-top:100px;
}

.panel {
	width: 100%;
  height: calc(100vh - 64px);
  display: flex;
  justify-content: center;
  font-weight: 600;
  font-size: 1.5em;
  text-align: center;
  position: relative;
  box-sizing: border-box;
  padding: 10px;
  background:#f8f8f8;
  overflow:hidden;

}


.section-3 {
    border: 10px solid blue

}
.height {
  background:red;
  height:200vh;
}

.panel h1 {
  font-size: 17vw;
  letter-spacing:-0.05em;
  font-weight: 600;
  margin: 0 auto;
  text-transform:uppercase;
}





              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

var panels = gsap.utils.toArray(".panel");
panels.pop();

panels.forEach((panel, i) => {
  
  // Get the element holding the content inside the panel
  let innerpanel = panel.querySelector(".panel-content");
  
  // Get the Height of the content inside the panel
  let panelHeight = innerpanel.offsetHeight;
  
  // Get the window height
  let windowHeight = window.innerHeight;
  
  let difference = panelHeight - windowHeight;
  
  // ratio (between 0 and 1) representing the portion of the overall animation that's for the fake-scrolling. We know that the scale & fade should happen over the course of 1 windowHeight, so we can figure out the ratio based on how far we must fake-scroll
  let fakeScrollRatio = difference > 0 ? (difference / (difference + windowHeight)) : 0;
  
  // if we need to fake scroll (because the panel is taller than the window), add the appropriate amount of margin to the bottom so that the next element comes in at the proper time.
  if (fakeScrollRatio) {
    panel.style.marginBottom = panelHeight * fakeScrollRatio + "px";
  }
  
  let tl = gsap.timeline({
    scrollTrigger:{
      trigger: panel,
      start: "bottom bottom",
      end: () => fakeScrollRatio ? `+=${innerpanel.offsetHeight}` : "bottom top",
      pinSpacing: false,
      pin: true,
      scrub: true
    }
  });
  
  // fake scroll. We use 1 because that's what the rest of the timeline consists of (0.9 scale + 0.1 fade)
  if (fakeScrollRatio) {
    tl.to(innerpanel, {y:-difference, duration: 1 / (1 - fakeScrollRatio) - 1, ease: "none"});
  }
  tl.fromTo(panel, {opacity:1}, {opacity: 0.5, duration: 0.5}, 0.4)
    .to(panel, {opacity:0, duration: 0.1});
});

              
            
!
999px

Console