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="w-full h-screen flex justify-center">
  <div class="container mx-auto p-8 flex flex-col justify-center items-center">
    <h1 class="text-4xl text-center font-semibold mb-12">GSAP ScrollTrigger Panels Container Animation</h1>
    <p class="text-lg font-medium">Scroll down to see a horizontal panels animation using Container Animation</p>
  </div>
</div>
<div class="w-full h-screen overflow-hidden" id="slidesWrapper">
  <div class="slides-container flex flex-nowrap w-[400%]">
    <div class="slide w-full h-screen bg-gray-200 flex justify-center items-center">
      <div class="w-4/5">
        <div class="w-full p-6">
          <h2 class="text-3xl text-center font-semibold text-gray-800 mb-6">Keep scrolling to see the container animation of the panels to the right.</h2>
        </div>
      </div>
    </div>
    <div class="slide w-full h-screen bg-gray-200 flex justify-center items-center">
      <div class="card-container border w-4/5">
        <div class="card w-full border bg-white rounded-lg p-6">
          <h2 class="text-3xl font-semibold text-gray-800 mb-6">Panel One</h2>
          <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae, tempora! Laudantium repudiandae cum sed laborum repellendus dolore sint veniam sit quasi, nemo itaque mollitia magnam quas doloremque? Sit, ex voluptate.</p>
        </div>
      </div>
    </div>
    <div class="slide w-full h-screen bg-gray-200 flex justify-center items-center" id="longPing">
      <div class="card-container border w-4/5">
        <div class="card w-full border bg-white rounded-lg p-6">
          <h2 class="text-3xl font-semibold text-gray-800 mb-6">Panel Two</h2>
          <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae, tempora! Laudantium repudiandae cum sed laborum repellendus dolore sint veniam sit quasi, nemo itaque mollitia magnam quas doloremque? Sit, ex voluptate.</p>
        </div>
      </div>
    </div>
    <div class="slide w-full h-screen bg-gray-200 flex justify-center items-center">
      <div class="card-container border w-4/5">
        <div class="card w-full border bg-white rounded-lg p-6">
          <h2 class="text-3xl font-semibold text-gray-800 mb-6">Panel Three</h2>
          <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae, tempora! Laudantium repudiandae cum sed laborum repellendus dolore sint veniam sit quasi, nemo itaque mollitia magnam quas doloremque? Sit, ex voluptate.</p>
        </div>
      </div>
    </div>
  </div>
</div>
<section class="w-full h-screen bg-gray-800 text-white px-4 py-2">FINAL SECTION</section>
              
            
!

CSS

              
                
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);
const slides = gsap.utils.toArray(".slide");
const t = gsap
  .timeline({
    scrollTrigger: {
      trigger: "#slidesWrapper",
      start: "top top",
      end: "+=2000",
      pin: true,
      scrub: true,
      snap: 1 / (slides.length - 1),
      markers: true
    }
  })
  .to(slides, {
    xPercent: -(100 * (slides.length - 1)),
    ease: "none"
  });

const cardContainers = gsap.utils.toArray(".card-container");
const cards = gsap.utils.toArray(".card");
cards.forEach((card, index) => {
  gsap.from(card, {
    opacity: 0.2,
    scale: 0.5,
    transformOrigin: "center center",
    ease: "none",
    scrollTrigger: {
      trigger: cardContainers[index],
      containerAnimation: t,
      start: "left 75%",
      end: "left 25%",
      markers: { startColor: "fuchsia", endColor: "fuchsia" },
      scrub: true
    }
  });
});

              
            
!
999px

Console