Code

GSAP

ScrollTrigger

Advanced Animate elements on scroll using the ScrollTrigger plugin. scrub ties animation progress directly to scroll position. Scroll the panel below. GSAP Docs

↓ Scroll this panel

Slide In
Scale Up
Fade Rotate
Color Shift
Skew In
import { ScrollTrigger } from 'gsap/ScrollTrigger';

gsap.registerPlugin(ScrollTrigger);

cards.forEach((card, i) => {
  ScrollTrigger.create({
    trigger: card,
    scroller: scrollPanel,  // custom scroller
    start: 'top 90%',
    end: 'top 30%',
    scrub: 0.8,  // lag behind scroll
    animation: gsap.fromTo(card,
      // different 'from' per card
      fromVars[i],
      // shared 'to'
      {
        x: 0, scale: 1,
        rotation: 0, skewX: 0,
        opacity: 1, ease: 'none'
      }
    ),
  });
});