In the Skill's Own Terms
ScrollTrigger is GSAP's plugin for scroll-linked animation: firing tweens and timelines at scroll positions, pinning sections, scrubbing progress to scroll, and driving a timeline through a start/end range.
It lays out the config vocabulary in full — trigger, start/end including clamp() and relative values, endTrigger, scrub, toggleActions, pin and pinSpacing, snap, scroller, id, refreshPriority — and adds ScrollTrigger.batch() for staggered reveals that arrive together, scrollerProxy() for third-party smooth scrollers, and containerAnimation for fake horizontal scroll. Defaults are stated per option, alongside a best-practices checklist and an explicit Do Not list covering React cleanup, refresh order, ease and leftover markers.
What it produces
- A tween or timeline whose progress is tied to scroll position through the trigger's start-to-end range.
- A standalone ScrollTrigger created without a linked tween, used with callbacks for custom behaviour such as updating UI from self.progress.
- An Array of ScrollTrigger instances, one per batch target, returned by ScrollTrigger.batch().
- Nested tweens that fire based on the horizontal movement produced by a containerAnimation tween.
How It Works
- 01Register the Plugin Once
ScrollTrigger ships as a plugin rather than part of the core animation API, so it is registered a single time after the script loads, before any scrollTrigger config runs.
- 02Attach a scrollTrigger Config
A tween or timeline gets a scrollTrigger object naming the trigger element plus a start and end describing trigger position against viewport position.
- 03Choose How Scroll Drives the Playhead
Scrub links progress continuously to scroll position, optionally with a numeric catch-up delay, while toggleActions fires discrete play/reverse actions at the four crossings.
- 04Pin a Section and Scrub a Timeline
Pinning holds the trigger element while the range is active, and a timeline attached to that ScrollTrigger advances its children across the same start-to-end span.
- 05Batch Elements That Arrive Together
ScrollTrigger.batch() creates one ScrollTrigger per target and collects their callbacks over a short interval so elements entering near-simultaneously can be animated with a stagger in one call.
- 06Kill Instances When Content Goes Away
Removing animated elements or changing pages, as in a single-page app, requires killing the associated instances so they do not keep running against stale elements.