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="filler">Please Scroll Down</section>
  
<section id="pinned-anim" class="our-schools-gsap ">
    <div class="cont">
        <div class="row">
            <div class="col our-schools-col">
                <div class="our-schools-slider-selector">
                  <div class="title">Our Schools</div>
                  <div class="our-schools-slider-item__title school-title-0 active" data-index="0">Nursery</div>
                  <div class="our-schools-slider-item__title school-title-1" data-index="1">Pre Prep</div>
                  <div class="our-schools-slider-item__title school-title-2" data-index="2">Junior</div>
                  <div class="our-schools-slider-item__title school-title-3" data-index="3">Senior</div>
                  <div class="our-schools-slider-item__title school-title-4" data-index="4">Sixth Form</div>
               </div>
          </div>
          <div class="col">
             <div class="articles">
                <div class="article slide-article relative-clone">
                </div>
                 <div class="article slide-article slide-1" id="article-1" data-slider_index="1">
                    <h3 class="animate_it active">Age 2 - 4</h3>
                    <h5>Nursery School</h5>
                    <p class="animate_it active">Lorem ipsum dollor sit amet</p>
                    <a class="arrow-button" href="#">
                      <div class="arrow-button__text">Link Text</div>
                      <div class="arrow-button__arrow right"><i></i></div>
                    </a>
                 </div>
                 <div class="article slide-article slide-2" id="article-2" data-slider_index="2">
                    <h3 class="animate_it active">Age 4 - 9</h3>
                    <h5>Pre Prep</h5>
                    <p class="animate_it active">Lorem ipsum dollor sit amet</p>
                    <a class="arrow-button" href="#">
                      <div class="arrow-button__text">Link Text</div>
                      <div class="arrow-button__arrow right"><i></i></div>
                    </a>
                 </div>
                 <div class="article slide-article slide-3" id="article-3" data-slider_index="3">
                    <h3 class="animate_it active">Age 9 - 13</h3>
                    <h5>Junior School</h5>
                    <p class="animate_it active">Lorem ipsum dollor sit amet</p>
                    <a class="arrow-button" href="#">
                      <div class="arrow-button__text">Link Text</div>
                      <div class="arrow-button__arrow right"><i></i></div>
                    </a>
                 </div>
                 <div class="article slide-article slide-4" id="article-4" data-slider_index="4">
                    <h3 class="animate_it active">Age 13 - 16</h3>
                    <h5>Senior School</h5>
                    <p class="animate_it active">Lorem ipsum dollor sit amet</p>
                    <a class="arrow-button" href="#">
                      <div class="arrow-button__text">Link Text</div>
                      <div class="arrow-button__arrow right"><i></i></div>
                    </a>
                 </div>
                 <div class="article slide-article slide-5" id="article-5" data-slider_index="5">
                    <h3 class="animate_it active">Age 16 - 18</h3>
                    <h5>Sixth Form College</h5>
                    <p class="animate_it active">Lorem ipsum dollor sit amet</p>
                    <a class="arrow-button" href="#">
                      <div class="arrow-button__text">Link Text</div>
                      <div class="arrow-button__arrow right"><i></i></div>
                    </a>
                 </div>
            </div>
        </div>
    </div>
</section>
  
<section class="filler">Thanks for looking</section>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
  font-family: verdana, sans-serif;
}
body {
  margin: 0;
  padding: 0;
}

$red: rgb(244, 22, 18);

#pinned-anim {
  
  background: linear-gradient(180deg, rgba(83, 86, 90, 0.5) -24.09%, rgba(213, 210, 210, 0) 58.11%);
  min-height: clamp(900px, 100vh, 1500px);
  @media(min-width: 992px) {
    max-height: 100vh;
    overflow: hidden;
  }
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
  .cont {
    height: 100%;
    width: 100vw;
    .row {
      position: relative;
      display: flex;
      align-items: center;
      //justify-content: space-between;
      height: 100%;
      .col {
        display: flex;
        align-items: center;
        &.our-schools-col {
          background: $red;
          color: white;
          height: 100%;
          position: relative;
          z-index: 1;
          padding: 20px;
          @media(min-width: 992px) {
            padding: 30px 30px 30px 130px;
          }
          &:before {
              position: absolute;
              content: '';
              left: -10px;
              bottom: -90px;
              width: 300px;
              height: 450px;
              background-image: url('../assets/src/img/logo-white-opaque.png');
              background-size: 300px;
              background-repeat: no-repeat;
              background-position: bottom left;
              pointer-events: none;
          }
          &:after {
            background: $red;
            position: absolute;
            content: '';
            right: -200px;
            top: 0;
            width: 200px;
            height: 100%;
          }
          .our-schools-slider-item__title {
            font-family: "Rams W01", sans-serif;
            font-weight: 300;
            font-size: clamp(30px, 2.604vw, 50px);
            padding: 10px 0;
            cursor: pointer;
            &.active {
              font-weight: 700;
            }
          }
        }
        &:first-of-type {
          width: 40%;
        }
        &:last-of-type {
          width: 50%;
          position: relative;
          z-index: 2;
          display: flex;
          height: 100%;
          .articles {
            position: relative;
            display: flex;
            align-items: center;
            visibility: hidden;
            height: 80%;
            width: 100%;
            .article {
              width: 100%;
              display: flex;
              flex-direction: column;
              justify-content: flex-end;
              align-items: flex-start;
              position: absolute;
              left: 0;
              height: 100%;
              border-radius: 25px;
              color: white;
              padding: 40px 40px 80px;
              background-position: center;
              background-repeat: no-repeat;
              background-size: cover;
              background-image: url('https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg');
              h3 {
                font-size: clamp(30px, 2.1vw, 40px);
                margin: 0;
                padding: 0;
                line-height: 1.2;
              }
              h5 {
                font-size: clamp(20px, 1.6vw, 25px);
                margin: 0;
                padding: 0;
                line-height: 1.2;
              }
              p {
                color: white;
                font-size: clamp(16px, 1.08vw, 20px);
                margin: 0;
                padding: 0;
              }
              a {
                color: white;
              }
              .arrow-button {
                margin-top: 25px;
                .arrow-button__text {
                  font-size: 20px;
                  font-weight: 600;
                  text-transform: uppercase;
                }
                .arrow-button__arrow {
                  background: white;
                  color: $red;
                }
              }
              &.relative-clone {
                position: relative;
                visibility: hidden;
              }
            }
          }
        }
      }
    }
  }
}

.filler {
  text-align: center;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp( 40px, 5.208vw, 100px);
  &:first-of-type {
      background: linear-gradient(360deg, rgba(83, 86, 90, 0.5) -24.09%, rgba(213, 210, 210, 0) 58.11%);
  }
}
              
            
!

JS

              
                $(document).ready(function () {
    const $triggers = $('.our-schools-slider-item__title');

    const timeline = gsap.timeline({
        scrollTrigger: {
            trigger: "#pinned-anim",
            pin: "#pinned-anim",
            start: "top top",
            end: () => `+=100%`,
            pin: true,
            pinSpacing: true,
            scrub: 1,
            invalidateOnRefresh: true,
            markers: true
        },
    });

    function pinStats() {
        $('.articles').css({'visibility': 'visible'});
        timeline.fromTo(".slide-1", {y: 0}, {y: '-100vh'}, 0.5);
        timeline.fromTo(".slide-2", {y: '100vh'}, {y: 0,}, "<");
        timeline.to(".slide-2", {y:  '-100vh'}, "+=0.5");
        timeline.fromTo(".slide-3", {y: '200vh'}, {y: 0,}, "<");
        timeline.to(".slide-3", {y:  '-200vh'}, "+=0.5");
        timeline.fromTo(".slide-4", {y: '300vh'}, {y: 0,}, "<");
        timeline.to(".slide-4", {y:  '-300vh'}, "+=0.5");
        timeline.fromTo(".slide-5", {y: '100vh'}, {y: 0}, "<");
        timeline.to({}, {duration: 0.5});
    }

    function updateSlideIndicators() {
        // get the position of the timeline
        const position = timeline.time();

        // get the index of the active slide based on the position
        let activeIndex;
        if (position < 1) {
            activeIndex = 0;
        } else if (position < 2) {
            activeIndex = 1;
        } else if (position < 3) {
            activeIndex = 2;
        } else if (position < 4) {
            activeIndex = 3;
        } else {
            activeIndex = 4;
        }

        // update the active state of the slide indicators
        $('.our-schools-slider-item__title').removeClass('active');
        $('.our-schools-slider-item__title').eq(activeIndex).addClass('active');
    }

    function handleSlideIndicatorClick() {
        const index = $(this).data('index');
        // timeline.seek(index);
        $('.our-schools-slider-item__title').removeClass('active');
        $(this).addClass('active');
        jumpToSlide(index);
    }

    function jumpToSlide(index) {
        const currentPosition = timeline.time();

        const duration = '0.5';

        const jumpTimeline = gsap.timeline();
        jumpTimeline.fromTo('.articles', { y: currentPosition * 100 + 'vh' }, { y: '0vh', duration: duration, ease: 'power2.inOut' });

        timeline.seek(index);

        jumpTimeline.play();



        // scroll to the target section using GSAP
        gsap.to(window, {
            duration: 1,
            scrollTo: {
                y: $targetSection.offset().top
            },
            ease: "power2.inOut"
        });
    }


    $('.our-schools-slider-item__title').on('click', handleSlideIndicatorClick);

    timeline.eventCallback('onUpdate', updateSlideIndicators);

    window.addEventListener("load", function (event) {
        pinStats();
    });

});
              
            
!
999px

Console