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

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

              
                <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;
}

body {
  overflow-x: hidden;
  overflow-y: scroll;
}


.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;
  border: 10px solid yellow
}


.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
  var innerpanel = panel.querySelector(".panel-content");
  
  // Get the Height of the content inside the panel
  var panelHeight = innerpanel.offsetHeight;
  
  // Get the window height
  var windowHeight = window.innerHeight;
  
  var difference = panelHeight - windowHeight ;

  // Check if the Panel content is taller than the viewport
  if (panelHeight <= windowHeight) {
    
   // If the content is smaller or equal to 100vh then use this timeline
  let tl = gsap.timeline({
    scrollTrigger:{
      trigger: panel,
      start: "bottom bottom",
      pinSpacing: false,
      pin:true,
      scrub: true
    }
  })
  
tl.fromTo(panel, 1, {scale:1, opacity:1}, {scale:0.5, opacity:0.5})
.to(panel, 0.1, {opacity:0})
    
  
  }  else {
    
    // If the content is taller than 100vh then use this timeline which virtual scrolls the content within the panel

    let tl = gsap.timeline({
    scrollTrigger:{
      trigger:panel,
      start: "top 63px",
      endTrigger:innerpanel,
      end:`+=${panelHeight + windowHeight }`,
      pinSpacing: true,
      pin:true,
      scrub: true
    }})
    
   
    tl.to(innerpanel, 0.5, {y:-difference})
    .fromTo(panel,0.5, {scale:1, opacity:1}, {scale:0.5, opacity:0.5})
    .to(panel, 0.1, {opacity:0})
  }
  });

              
            
!
999px

Console