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

              
                <section class="grid-container full section one">
  <div class="grid-container">
    <div class="grid-x grid-padding-x">
      <div class="cell">
        <h1>Lorem Ipsum.</h1>
      </div>
    </div>
  </div>
</section>
<section class="grid-container full section two">
  <div class="grid-container">
    <div class="grid-x grid-padding-x">
      <div class="cell">
        <h1>Lorem Ipsum.</h1>
      </div>
    </div>
  </div>
</section>
<section class="grid-container full section three">
  <div class="grid-container">
    <div class="grid-x grid-padding-x">
      <div class="cell">
        <h1>Lorem Ipsum.</h1>
      </div>
    </div>
  </div>
</section>
<section class="grid-container full section four">
  <div class="grid-container">
    <div class="grid-x grid-padding-x">
      <div class="cell one" data-img-src="https://images.unsplash.com/photo-1516647768-31ff0cef8821?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=870&amp;q=80">
        <h1>Lorem One.</h1>
      </div>
      <div class="cell two" data-img-src="https://images.unsplash.com/photo-1516648064-ee10acfa64db?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=863&amp;q=80">
        <h1>Lorem Two.</h1>
      </div>
      <div class="cell three" data-img-src="https://images.unsplash.com/photo-1516647072-a39e59e34b97?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=870&amp;q=80">
        <h1>Lorem Three.</h1>
      </div>
      <div class="imgs">
        <img src="https://images.unsplash.com/photo-1516647768-31ff0cef8821?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=870&amp;q=80" alt="Lil' Image"/>
      </div>
    </div>
  </div>
</section>
<section class="grid-container full section five">
  <div class="grid-container">
    <div class="grid-x grid-padding-x">
      <div class="cell">
        <h1>Lorem Ipsum.</h1>
      </div>
    </div>
  </div>
</section>
<section class="grid-container full section six">
  <div class="grid-container">
    <div class="grid-x grid-padding-x">
      <div class="cell">
        <h1>Lorem Ipsum.</h1>
      </div>
    </div>
  </div>
</section>
<section class="grid-container full section seven">
  <div class="grid-container">
    <div class="grid-x grid-padding-x">
      <div class="cell">
        <h1>Lorem Ipsum.</h1>
      </div>
    </div>
  </div>
</section>
              
            
!

CSS

              
                $companyColourOne:      #FEFEFE;
$companyColourTwo:      #E8EDDF;
$companyColourThree:    #CFDBD5;
$companyColourFour:     #F5CB5C;
$companyColourFive:     #4B4E4B;
$companyColourSix:      #242423;
$companyColourSeven:    #0A0A0A;

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&family=Manrope:wght@400;600&display=swap');

$montserrat:            'Montserrat', sans-serif;
$manrope:               'Manrope', sans-serif;

// START; Lenis Scroll.
html {
  &.lenis {
    height: auto;
  }
}

.lenis {
  &.lenis-smooth {
    scroll-behavior: auto;

    [data-lenis-prevent] {
      overscroll-behavior: contain;
    }
  }

  &.lenis-scrolling {
    iframe {
      pointer-events: none;
    }
  }

  &.lenis-stopped {
    overflow: hidden;
  }
}
// END; Lenis Scroll.

h1 {
  margin: 0;
  font-family: $montserrat;
  font-size: 32px;
  font-weight: 600;
  font-style: normal;
  line-height: 42px;
}

.section {
  min-height: 100vh;
  padding-top: 120px;
  padding-bottom: 120px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  overflow: hidden;

  &.one {
    background-color: $companyColourOne;
    z-index: 1;

    * {
      color: $companyColourSeven;
    }
  }

  &.two {
    background-color: $companyColourTwo;
    z-index: 2;

    * {
      color: $companyColourSeven;
    }
  }

  &.three {
    background-color: $companyColourThree;
    z-index: 3;

    * {
      color: $companyColourSeven;
    }
  }

  &.four {
    position: relative;
    background-color: $companyColourFour;
    z-index: 4;

    * {
      color: $companyColourSeven;
    }

    .grid-container {
      .grid-x {
        position: relative;

        .cell {
          height: calc(100vh - (120px * 2));
          display: flex;
          justify-content: flex-start;
          align-items: center;
        }

        .imgs {
          width: 50%;
          height: calc(100vh - (120px * 2));
          top: 0;
          right: 0;
          position: absolute;
          overflow: hidden;

          img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: center;
          }
        }
      }
    }
  }

  &.five {
    background-color: $companyColourFive;
    z-index: 5;

    * {
      color: $companyColourOne;
    }
  }

  &.six {
    background-color: $companyColourSix;
    z-index: 6;

    * {
      color: $companyColourOne;
    }
  }

  &.seven {
    background-color: $companyColourSeven;
    z-index: 7;

    * {
      color: $companyColourOne;
    }
  }

  .grid-container {
    width: 100%;
  }
}

@media screen and (min-width: 640px) {
  h1 {
    font-size: 40px;
    line-height: 50px;
  }
}

@media screen and (min-width: 1024px) {
  h1 {
    font-size: 48px;
    line-height: 58px;
  }
}

@media screen and (min-width: 1200px) {
  h1 {
    font-size: 56px;
    line-height: 66px;
  }
}

@media screen and (min-width: 1440px) {
  h1 {
    font-size: 64px;
    line-height: 74px;
  }
}

@media screen and (min-width: 1920px) {

}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

(function($) {
  $(document).ready(function() {
    initialiseApp();

    function initialiseApp() {
      initialiseGSAPScrollTriggerPinning();
      initialiseGSAPScrollTriggerPinningInsidePinning();
      initialiseLenisScroll();
    }

    function initialiseGSAPScrollTriggerPinning() {
      gsap.utils.toArray('.section').forEach((section, i) => {
        const nextSection = section.nextElementSibling;

        ScrollTrigger.normalizeScroll({
          allowNestedScroll: true
        });

        if (section.classList.contains('four')) {

        } else {
          ScrollTrigger.normalizeScroll(false);

          ScrollTrigger.create({
            trigger: section,
            start: 'bottom bottom',
            pin: true,
            pinType: 'fixed',
            pinSpacing: false,
            anticipatePin: 1,
            scrub: .5,
            invalidateOnRefresh: true,
            ease: 'none'
          })
        }

        gsap.to(section, {
          opacity: 0,
          scrollTrigger: {
            trigger: nextSection,
            start: 'top bottom',
            end: 'top top',
            stagger: .1,
            scrub: .5,
            ease: 'Power4.easeInOut'
          }
        });
      });
    }

    function initialiseGSAPScrollTriggerPinningInsidePinning() {
      let sectionFour = gsap.timeline({
        scrollTrigger: {
          trigger: '.section.four',
          start: 'top bottom',
          end: 'top top'
        }
      });

      let cells = $('.section.four .cell');
      let end = (cells.innerHeight() * (cells.length));
      // let end = (cells.innerHeight() * (cells.length - 1));

      sectionFour.fromTo('.section.four .imgs', {
        autoAlpha: 1,
      }, {
        autoAlpha: 1,
        duration: .3,
        ease: 'Power4.easeInOut',
        scrollTrigger: {
          trigger: '.section.four .imgs',
          start: "top 120px",
          end: end + 'px',
          pin: true
        }
      });

      gsap.utils.toArray('.section.four .cell').forEach(cell => {
        ScrollTrigger.create({
          trigger: cell,
          start: "top center",
          onEnter: function() {
            if ($(cell).hasClass('one')) {
              // do nothing
            } else {
              let imgSrc = $(cell).attr('data-img-src');

              $('.section.four .imgs img').attr('src', imgSrc);

              gsap.fromTo('.section.four .imgs img', {
                autoAlpha: 0,
              }, {
                autoAlpha: 1,
                duration: .6,
                ease: 'Power4.easeInOut',
              });
            }
          },
          onLeaveBack: function() {
            if ($(cell).hasClass('one')) {
              // do nothing
            } else {
              let imgSrc = $(cell).prev().attr('data-img-src');

              $('.section.four .imgs img').attr('src', imgSrc);

              gsap.fromTo('.section.four .imgs img', {
                autoAlpha: 0,
              }, {
                autoAlpha: 1,
                duration: .6,
                ease: 'Power4.easeInOut',
              });
            }
          }
        });
      });
    }

    function initialiseLenisScroll() {
      const lenis = new Lenis({
        smoothWheel: true,
        duration: 1.2
      });

      lenis.on('scroll', ScrollTrigger.update);

      gsap.ticker.add((time) => {
        lenis.raf(time * 1000);
      });

      gsap.ticker.lagSmoothing(0);
    }
  });
}) (jQuery);
              
            
!
999px

Console