GSAP ScrollTrigger generator

Test start and end markers in a live scroll viewport, toggle scrub, pin and stagger, then copy reduced-motion-safe GSAP 3.15.0 boilerplate for Vanilla JS, React, Vue or WordPress.

Presets

Trigger positions

Motion & behaviour

Flags

Live scroll preview Waiting
progress 0%

Scroll inside this frame to cross the start and end lines.

.reveal

Trigger element

Crosses scroller-start and animates according to your settings.

End of preview scroll track.

Trigger fires when the element's top reaches 85% down the viewport.

<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/ScrollTrigger.min.js"></script>
<script>
  gsap.registerPlugin(ScrollTrigger);

  const mm = gsap.matchMedia();
  mm.add('(prefers-reduced-motion: no-preference)', () => {
    gsap.from('.reveal', {
      y: 40,
      opacity: 0,
      duration: 0.7,
      ease: 'power2.out',
      scrollTrigger: {
        trigger: '.reveal',
        start: 'top 85%',
        end: 'bottom 20%',
        toggleActions: 'play none none none',
        markers: true,
      },
    });
  });
</script>

How to read ScrollTrigger start and end strings

Two tokens: element, then viewport

In start: 'top 85%', the first word (top) is the edge on your trigger element and the second (85%) is the line measured down from the top of the viewport. When those two lines meet, the trigger fires.

Relative scroll distances for pin and scrub

When pinning a section, pass a relative end such as '+=600' or '+=100%'. ScrollTrigger holds the section fixed for that exact pixel distance and automatically inserts spacer height below it.

Remove markers before shipping

Keep markers: true turned on while dialing in trigger positions, then delete it before deploy. If triggers fire early or late after images load, give media explicit dimensions or call ScrollTrigger.refresh().

Production ScrollTrigger examples to inspect

Each effect below ships with live demos, responsive breakpoints, cleanup and reduced-motion fallbacks already wired up.

ScrollTrigger generator questions

How do GSAP ScrollTrigger start and end values work?

Each value has two tokens: a point on the trigger element followed by a point in the viewport. For example, start: 'top 85%' fires when the top of the trigger element reaches 85% down from the top of the viewport. Relative end values such as '+=600' end 600 pixels of scroll after the start point.

When should I use scrub instead of toggleActions?

Use toggleActions for entrance animations that play once on their own clock when scrolled into view. Add scrub when progress should stay locked to the scrollbar: scrub: true tracks scroll directly, while a number such as scrub: 1 adds one second of smoothing. When scrub is enabled, ScrollTrigger ignores toggleActions.

Why does the generated code wrap animations in gsap.matchMedia()?

gsap.matchMedia() lets you gate animations on (prefers-reduced-motion: no-preference) and automatically reverts inline styles and ScrollTriggers if the user preference or breakpoint changes. In React and Vue, reverting the context or matchMedia instance on unmount also prevents leaked ScrollTriggers across route changes.

Is GSAP ScrollTrigger free to use on commercial sites?

Yes. GSAP core, ScrollTrigger and every other official plugin are free for commercial use under the GSAP Standard License. Load them from jsDelivr or install the gsap package from npm with no account or licence key.