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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="scroller">
      
			<section class="orange">
				<div class="text">This is some text inside of a div block.</div>
			</section>
      
			<section class="black">
        
				<div class="text-wrap">          
          <div class="panel-text blue-text">
            <p>One</p>
            <p>is the</p>
            <p>loneliest number</p>
            <p>that you'll ever do</p>
          </div> 
          <div class="panel-text red-text">
            <p>Two</p>
            <p>can be as bad as one</p>
            <p>It's the loneliest number</p>
            <p>since the number one</p>
          </div>   
          <div class="panel-text orange-text">
            <p>One</p>
            <p>is the</p>
            <p>loneliest number</p>
            <p>that you'll ever do</p>
          </div> 
          <div class="panel-text purple-text">
            <p>Two</p>
            <p>can be as bad as one</p>
            <p>It's the loneliest number</p>
            <p>since the number one</p>
          </div> 
        </div>
        
				<div class="p-wrap">
					<div class="panel blue"></div> 
					<div class="panel red"></div>
					<div class="panel orange"></div> 
					<div class="panel purple"></div> 
				</div>
        
			</section>
      
			<section class="blue"></section>
      
		</div>
              
            
!

CSS

              
                body,
html {
  margin: 0;
  padding: 0;
}
.scroller {
  height: 100vh;
}

section {
  height: 100vh;
}

section.orange {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;

  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  background-color: orange;
}



section.black {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;

  -webkit-justify-content: space-around;
  -ms-flex-pack: distribute;
  justify-content: space-around;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  background-color: black;
}

section.blue {
  background-color: blue;
}



.text {
  color: white;
}


.text-wrap {
  position: relative;
  overflow: hidden;
  width: 450px;
  height: 80vh;
}

.panel-text {
  position: absolute;
  left: 0%;
  top: 0%;
  right: 0%;
  bottom: 0%;
  z-index: 1;
  width: 100%;
  height: 100%;
  
  font-size: 30px;
  text-transform: uppercase;
  font-weight: 900;
  text-align:center;
  background-color: black; 
  
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.panel-text p {
  margin: 10px;
}

.panel-text.blue-text {
  color: blue;
}

.panel-text.red-text {
  color: red;
}

.panel-text.purple-text {
  color: purple;
}

.panel-text.orange-text {
  color: orange;
}






.p-wrap {
  position: relative;
  overflow: hidden;
  width: 450px;
  height: 80vh;
}

.panel {
  position: absolute;
  left: 0%;
  top: 0%;
  right: 0%;
  bottom: 0%;
  z-index: 1;
  width: 100%;
  height: 100%;
}


.panel.blue {
  background-color: blue;
}

.panel.red {
  background-color: red;
}

.panel.orange {
  background-color: orange;
}

.panel.purple {
  background-color: purple;
}

              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);
let bodyScrollBar = Scrollbar.init(document.querySelector('.scroller'), {
  damping: 0.1,
  delegateTo: document,
});
ScrollTrigger.scrollerProxy(".scroller", {
  scrollTop(value) {
    if (arguments.length) {
      bodyScrollBar.scrollTop = value;
    }
    return bodyScrollBar.scrollTop;
  },
});
bodyScrollBar.addListener(ScrollTrigger.update);







gsap.set(".panel", { zIndex: (i, target, targets) => targets.length - i });

var images = gsap.utils.toArray('.panel:not(.purple)');

images.forEach((image, i) => {
   
   var tl = gsap.timeline({
     
     scrollTrigger: {
       trigger: "section.black",
       scroller: ".scroller",
       
       //start: () => "top -" + (window.innerHeight * (i + 0.33)),
       //start: () => "top -" + (window.innerHeight * (i + 0.5)),
       start: () => "top -" + (window.innerHeight * (i + 1.0)),
       
       end: () => "+=" + window.innerHeight,
       scrub: true,
       toggleActions: "play none reverse none",
       invalidateOnRefresh: true,     
     }
     
   })
   
   tl
   .fromTo(image, { height: () => { return "100%" } }, { height: () => { return "0%" } })
   ;
   
});
 
 



 gsap.set(".panel-text", { zIndex: (i, target, targets) => targets.length - i });

 var texts = gsap.utils.toArray('.panel-text');
 
 texts.forEach((text, i) => {   
   
   var lines = text.querySelectorAll('p');
   
   var tl = gsap.timeline({
     
     scrollTrigger: {
       trigger: "section.black",
       scroller: ".scroller",
       start: () => "top -" + (window.innerHeight*i),
       end: () => "+=" + window.innerHeight,
       scrub: true,
       toggleActions: "play none reverse none",
       invalidateOnRefresh: true,     
     }
     
   })
   
   tl
   .fromTo(lines[0], { y: () => { return "25vh" }, opacity: () => { return 0 } }, { y: () => { return "0vh" }, opacity: () => { return 1 } })
   .fromTo(lines[1], { y: () => { return "25vh" }, opacity: () => { return 0 } }, { y: () => { return "0vh" }, opacity: () => { return 1 } })
   .fromTo(lines[2], { y: () => { return "25vh" }, opacity: () => { return 0 } }, { y: () => { return "0vh" }, opacity: () => { return 1 } })
   .fromTo(lines[3], { y: () => { return "25vh" }, opacity: () => { return 0 } }, { y: () => { return "0vh" }, opacity: () => { return 1 } })
   .to(text, { opacity: () => { return 0 } })
   ;
   
 });





ScrollTrigger.create({

    trigger: "section.black",
    scroller: ".scroller",
    scrub: true,
    markers: true,
    pin: true,
    start: () => "top top",
    end: () => "+=" + ((images.length + 1) * window.innerHeight),
    invalidateOnRefresh: true,

});
              
            
!
999px

Console