Shack Logo
Dan's Sandbox
← Back to Blog
ANIMATION

CRAFTING SCROLL-DRIVEN ANIMATIONS WITH GSAP

Mar 2025·6 min read

Scroll-driven animations have become a hallmark of modern web experiences. Done well, they guide the user's attention, reveal content with purpose, and make an interface feel alive. GSAP's ScrollTrigger plugin is the most capable tool I've found for building these — it handles the hard parts of scroll math so you can focus on the creative side.

The key mental model is separating the animation from the trigger. A GSAP tween describes what should change (opacity, position, scale), while ScrollTrigger describes when it should happen (as the element enters the viewport, or pinned while scrolling through a percentage of the page). Once that separation clicks, complex sequences become straightforward to reason about.

Pinning is where ScrollTrigger really shines. You can pin an element in place while the page continues to scroll, then animate child elements within that pinned container — effectively creating a horizontal scroll inside a vertical scroll, or a full-screen scene that plays out over multiple scroll lengths. The Zoi and Sofi clones in my sandbox both rely on this technique heavily.

One trap to avoid: animating layout properties like width, height, or margin. These trigger browser reflows and will make your animations feel janky regardless of how well the rest is tuned. Stick to transform and opacity — they run on the compositor thread and stay smooth even on lower-end hardware.

The best advice I can give is to build the animation first at a fixed progress value, then attach ScrollTrigger. Debugging a broken animation while also fighting scroll timing is painful. Get the tween right in isolation, then hand control over to scroll.

GSAPScrollTriggerAnimation