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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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="wrapper overflow-hidden">
  <section class="panel vh-100 d-flex align-items-center justify-content-center position-absolute vw-100">
    <div class="panel__inner d-flex flex-column align-items-center position-relative">
      <svg class="path position-absolute" preserveAspectRatio="xMidYMid meet" xml:space="preserve" viewBox="0 0 1560.06 450.75" xmlns="http://www.w3.org/2000/svg">
        <path id="text-curve0" d="m.43 450.5c155.62-269.01 446.47-450 779.57-450s624 181 779.59 450" fill="none" stroke="none" stroke-miterlimit="10"></path>
        <text dominant-baseline="hanging">
          <textPath href="#text-curve0" startOffset="-218.4925">1st word</textPath>
        </text>
      </svg>
      <div class="text-center">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras risus tellus, consequat id dapibus in, ultrices eu purus. Vivamus commodo fringilla tellus sit amet luctus. Vivamus fermentum sapien quis nulla tincidunt pellentesque. Pellentesque nec turpis luctus, laoreet diam vestibulum, vulputate nisl. Vivamus id tellus id metus cursus interdum. Phasellus porttitor tortor vel malesuada sodales. Pellentesque tincidunt magna posuere condimentum dapibus.
      </div>
    </div>
  </section>
  <section class="panel vh-100 d-flex align-items-center justify-content-center position-absolute vw-100">
    <div class="panel__inner d-flex flex-column align-items-center position-relative">
      <svg class="position-absolute" preserveAspectRatio="xMidYMid meet" xml:space="preserve" viewBox="0 0 1560.06 450.75" xmlns="http://www.w3.org/2000/svg">
        <path id="text-curve1" d="m.43 450.5c155.62-269.01 446.47-450 779.57-450s624 181 779.59 450" fill="none" stroke="none" stroke-miterlimit="10"></path>
        <text dominant-baseline="hanging">
          <textPath href="#text-curve1" startOffset="-218.4925">2nd word</textPath>
        </text>
      </svg>
      <div class="text-center">Vivamus vitae pharetra lorem, id congue nisl. Aliquam posuere augue ut orci ultrices tempor. Morbi finibus eleifend dignissim. Integer iaculis sapien nisi. Duis ut neque ac nisi dapibus efficitur. In hac habitasse platea dictumst. Nullam pulvinar ultrices turpis, sit amet viverra felis tincidunt nec. Curabitur pharetra tortor odio. Quisque vel vehicula ipsum. Sed condimentum efficitur purus, vel varius sapien tristique nec. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam accumsan et massa vel egestas. Etiam ultricies convallis nibh, in varius lorem venenatis eget. Fusce varius tortor eget efficitur fringilla. Vestibulum id fringilla sapien, ut pellentesque justo. Nulla facilisi.
      </div>
    </div>
  </section>
  <section class="panel vh-100 d-flex align-items-center justify-content-center position-absolute vw-100">
    <div class="panel__inner d-flex flex-column align-items-center position-relative">
      <svg class="position-absolute" preserveAspectRatio="xMidYMid meet" xml:space="preserve" viewBox="0 0 1560.06 450.75" xmlns="http://www.w3.org/2000/svg">
        <path id="text-curve2" d="m.43 450.5c155.62-269.01 446.47-450 779.57-450s624 181 779.59 450" fill="none" stroke="none" stroke-miterlimit="10"></path>
        <text dominant-baseline="hanging">
          <textPath href="#text-curve2" startOffset="-218.4925">3rd word</textPath>
        </text>
      </svg>
      <div class="text-center">Pellentesque et molestie mauris, id pulvinar nibh. Maecenas a neque finibus tellus blandit aliquet nec eget ex. Proin pharetra dignissim fringilla. Proin rhoncus convallis pretium. Suspendisse pellentesque vitae dolor non aliquet. Cras sit amet tortor urna. Integer aliquam convallis purus sit amet viverra. Mauris at bibendum felis. In hac habitasse platea dictumst. Suspendisse metus ante, dignissim ac egestas sed, eleifend eget erat.
      </div>
    </div>
  </section>
</div>
<footer class="vh-100 d-flex align-items-center justify-content-center">
  <button class="button">
    Button
  </button>
</footer>
              
            
!

CSS

              
                .wrapper {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.panel {
  left: 0;
  top: 0;

  &__inner {
    max-width: 71rem;
    padding: 0 10rem;
  }

  svg {
    left: 50%;
    transform: translateX(-50%);
    top: -10rem;
    width: 120vw;
  }
}

button {
  transition: background-color 0.3s ease-in-out;
  background-color: red;

  &.enable {
    background-color: green;
  }
}

              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

// button animation
const btnBig = gsap.utils.toArray(".button");
btnBig.forEach((btn, index) => {
  gsap.to(btn, {
    scrollTrigger: {
      id: `button--${index}`,
      trigger: btn,
      toggleClass: "enable",
      markers: true
    }
  });
});

// main animation
const wrapper = gsap.utils.toArray(".wrapper");
const panels = gsap.utils.toArray(".panel");

const snapTo = 1 / (panels.length - 1);
console.log(snapTo);

const tl = gsap.timeline({
  scrollTrigger: {
    trigger: wrapper,
    scrub: 1,
    pin: true,
    start: "top top",
    snap: {
      snapTo,
      delay: 0
    },
    end: () => `+=${200 * panels.length}%`
  }
});

panels.forEach((panel, index) => {
  const pathLength = panel.querySelector("path").getTotalLength();
  const textPath = panel.querySelector("textPath");
  const textPathLength = textPath.getComputedTextLength();

  if (index > 0) {
    tl.to(panels[index - 1], {
      autoAlpha: 0,
      duration: 0.3
    });

    tl.from(panel, {
      autoAlpha: 0,
      duration: 0.3
    });
  }

  tl.fromTo(
    textPath,
    {
      attr: {
        startOffset: pathLength
      }
    },
    {
      attr: {
        startOffset: -textPathLength
      },
      duration: 2.5
    }
  );
});

ScrollTrigger.refresh();

              
            
!
999px

Console