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="o-scroll" id="o-scroll">
  
  <section class="hero">   
    <div class="hero__bottom">
      This is a title
    </div>
    <div class="hero__inner">
    </div>
    <div class="hero__inner">
    </div>
    <div class="hero__inner">
    </div>
    <div class="hero__inner">
    </div>
  </section>
  
  <div class="section-0" data-scroll data-scroll-speed="2">
    <p 
       data-scroll 
       data-scroll-direction="horizontal" 
       data-scroll-speed="-2"
       >
      Travelling leaves you speechless
    </p>
    <p 
       data-scroll 
       data-scroll-direction="horizontal" 
       data-scroll-speed="2"
       >
      Then it turns you to a storyteller
    </p>

    <cite>— Ibn Battuta</cite>
  </div>
  
  <section class="section text">
    
  		<div class="text-banner">

      <div class="text-banner__inner">
        <div class="f-1 fade-up-title">
        <span>
            This is a </span>
          <span>
            title
          </span>
        </div>
        <div class="text fade-up-text">
          <span> This is a </span>
          <span> text </span>
        </div>
      </div>
        
    </div>
    
  </section>
  
  <section class="section testing"> 
    
    <div class="title">
      This is a title
    </div>
    <div class="subtitle">
      This is text
    </div>
    
  </section>
  
    <div class="section-0" data-scroll data-scroll-speed="2">
    <p 
       data-scroll 
       data-scroll-direction="horizontal" 
       data-scroll-speed="-2"
       >
      Travelling leaves you speechless
    </p>
    <p 
       data-scroll 
       data-scroll-direction="horizontal" 
       data-scroll-speed="2"
       >
      Then it turns you to a storyteller
    </p>

    <cite>— Ibn Battuta</cite>
  </div>
  
  <section class="section text">
    
  		<div class="text-banner">

      <div class="text-banner__inner">
        <div class="f-1 fade-up-title">
          <span>
            This is a </span>
          <span>
            title
          </span>
        </div>
        <div class="text fade-up-text">
          <span> This is a </span>
          <span> text </span>
        </div>
      </div>
        
    </div>
    
  </section>
  
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Signika+Negative:300,400&display=swap');

body { 
  font-family: "Signika Negative", sans-serif; 
  font-weight: 400;
  margin: 0;
  padding: 0 20px;
  color:white;
}

.o-scroll {
  overflow: hidden !important;
}

.hero {
  height:100%;
  background-color:red;
  justify-content: center;
  
  
}
.hero__inner {
  height:100vh;
}
.hero__bottom {
    position:relative;
    height:100%;
    align-items:flex-end;
    vertical-align:center;
    display:flex;
  }

.title,
.f-1 {
    font-size:50px;
    line-height: 1.1em;
    margin: 20px 0;
}

.subtitle,
.text {
  font-size:40px;
}
.section {
  height: 100vh;
  position:relative;
  background:green;
}

.section.text {
  z-index: 1;
}

.text-banner {
  height:100vh;
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 0;
}

.text-banner__inner {
  align-self: center;
  text-align: center;
}



.footer {
  height: 100vh;
  background: salmon
}




.section-0 {
  margin-top: 20vh;
  text-align: center;
  color: #333;
}

p {
  font-size: 5vw;
}
cite {
  font-weight: 300;
  font-style: italic;
  font-size: 4.5vmin;
  display: block;
  padding: 8px 0;
  font-size: 3vw;
}

section.testing {
  background-color: orange;
  margin-top: -200vh;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
}
.fade-up-title span, .fade-up-text span {
  display:block;
}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);


const locoScroll = new LocomotiveScroll({
            el: document.querySelector(".o-scroll"),
            smooth: true
        });
        // each time Locomotive Scroll updates, tell ScrollTrigger to update too (sync positioning)
        locoScroll.on("scroll", ScrollTrigger.update);

        // tell ScrollTrigger to use these proxy methods for the ".o-scroll" element since Locomotive Scroll is hijacking things
        ScrollTrigger.scrollerProxy(".o-scroll", {
            scrollTop(value) {
                return arguments.length ? locoScroll.scrollTo(value, 0, 0) : locoScroll.scroll.instance.scroll.y;
            }, // we don't have to define a scrollLeft because we're only scrolling vertically.
            getBoundingClientRect() {
                return { top: 0, left: 0, width: window.innerWidth, height: window.innerHeight };
            },
            // LocomotiveScroll handles things completely differently on mobile devices - it doesn't even transform the container at all! So to get the correct behavior and avoid jitters, we should pin things with position: fixed on mobile. We sense it by checking to see if there's a transform applied to the container (the LocomotiveScroll-controlled element).
            pinType: document.querySelector(".o-scroll").style.transform ? "transform" : "fixed"
        });



    let tlm = gsap.timeline({
      scrollTrigger: {
        trigger: ".hero",
        scroller: ".o-scroll",
        start: "top top",
        scrub: true,
     
        end: "+=100%",
        marker:true,
      },
    });
    tlm.to(
      ".hero",
       { duration: 0.2, autoAlpha: 0 }, 2);


        gsap.set('.fade-up-title span, .fade-up-text span', {
            autoAlpha: 0,
            y: 100,
        })
gsap.utils.toArray(".section.text").forEach((section) => {
        var tls = gsap.timeline({
            scrollTrigger: {
                trigger: section,
                scroller: ".o-scroll",
                scrub: true,
                start: "top top",
                end: "+=500%",
                pin: true
            }
        });
  
const textTitle = section.querySelectorAll(".fade-up-title span");
      const textText = section.querySelectorAll(".fade-up-text span");

        tls
        .to('body', { duration: 5 }).to(textTitle, { duration: 1, autoAlpha: 1, y: 0 }, 0)
        .to(textText, { duration: 1, autoAlpha: 1, y: 0, }, 1)
        .to(textTitle, { duration: 1, autoAlpha: 0, y: -100 }, 3)
        .to(textText, { duration: 1, autoAlpha: 0, y: -100 }, 3)
});


        ScrollTrigger.create({
          trigger: ".section.testing",
          scroller: ".o-scroll",
          start: "top top",
          end: "+=100%",
          pin: true
        })

        const testing = gsap.to('section.testing', { autoAlpha: 1 })

        ScrollTrigger.create({
          trigger: ".section.testing",
          scroller: ".o-scroll",
          start: "top top",
          end: "+=100%",
          animation: testing,
          scrub: true,
        })



        // each time the window updates, we should refresh ScrollTrigger and then update LocomotiveScroll. 
        ScrollTrigger.addEventListener("refresh", () => locoScroll.update());

        // after everything is set up, refresh() ScrollTrigger and update LocomotiveScroll because padding may have been added for pinning, etc.
        ScrollTrigger.refresh();
              
            
!
999px

Console