Skip to main content
GSAP Animation TutorialArticle 14

GSAP ScrollTrigger Tutorial: Animate Elements on Scroll

Make animations begin when headings, cards, images and complete sections reach meaningful positions in the viewport.

GSAP ScrollTrigger Tutorial Animate Elements on Scroll - NavTechSolution

A normal GSAP entrance starts when JavaScript runs. If its target is far below the fold, the motion may finish before the visitor sees it. ScrollTrigger connects that animation to a useful scroll position.

gsap.from(".title", {
  y: 50,
  opacity: 0,
  duration: 0.8,
  scrollTrigger: {
    trigger: ".title",
    start: "top 80%"
  }
});
Normal GSAPPage loadAnimation
GSAP + ScrollTriggerUser scrollsTrigger reaches startAnimation
GSAP defines the motion. ScrollTrigger decides when scrolling activates it.

What you will learn

1

Load and register ScrollTrigger

2

Understand target, trigger, start and end

3

Reveal text, cards and visual content

4

Combine scroll activation with stagger and timelines

5

Debug positions without production markers

6

Design responsive, accessible scroll motion

1. What is GSAP ScrollTrigger?

ScrollTrigger is an official GSAP plugin for animations and interactions based on scroll position. It supports reveals, timelines, pinned scenes, scrubbed progress and storytelling, but this lesson focuses on fundamentals.

SCROLL ↓
VIEWPORT START LINEELEMENT · CARD
Trigger reaches line → GSAP starts
The watched element moves through a calculated viewport line.

2. GSAP vs ScrollTrigger

GSAPWHAT?x · opacity · scale
+
ScrollTriggerWHEN?top 80%
=
Scroll animationMotion at the right moment
Animation properties and scroll activation remain separate responsibilities.

3. Load ScrollTrigger

This site loads GSAP 3 from jsDelivr, so the page loads ScrollTrigger from the same GSAP 3 package after core GSAP—without loading core twice.

<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js"></script>

4. Register ScrollTrigger

if (typeof gsap !== "undefined" &&
    typeof ScrollTrigger !== "undefined") {
  gsap.registerPlugin(ScrollTrigger);
}

Registration tells GSAP that the plugin is available and prevents silent configuration confusion.

5. Your first ScrollTrigger animation

ScrollTrigger

Animate When Visible

This card animates as it reaches the trigger position.

6. Understanding trigger

The trigger is the element ScrollTrigger watches for positioning. It may also be the animated target, but it does not have to be.

START POSITION
↑ TRIGGER ELEMENT
ScrollTrigger compares the trigger’s geometry with the configured viewport position.

7. Target vs trigger

gsap.from(".image", {
  x: 80,
  opacity: 0,
  scrollTrigger: { trigger: ".content-section", start: "top 80%" }
});
Target.imageWhat GSAP animates
Trigger.content-sectionWhat ScrollTrigger watches
One section can trigger animation on a child image.

8. Understanding start

In start: "top 80%", top refers to the trigger element and 80% refers to the viewport. Activation occurs when those positions meet.

VIEWPORT 80%ELEMENT TOP
Element top meets viewport 80% → start

9. Basic start examples

top 90%Earlier near the viewport bottom
top 80%A common reveal point
top 70%Later, farther into view
top centerAt the viewport center

10. Interactive start position demo

START · 80%TRIGGER

Current start: top 80%

11. Markers

markers: true shows start/end guides during development. This production article uses a controlled diagram instead of enabling real markers.

startendTRIGGER CONTENT
Markers expose trigger and scroller positions while debugging.

12. Why markers matter

If an animation starts unexpectedly, markers help reveal a wrong selector, an unsuitable start, an already-active section or a layout shift.

13. Understanding end

scrollTrigger: {
  trigger: ".section",
  start: "top 80%",
  end: "bottom 20%"
}

start opens the active range; end closes it. For a basic entrance tween without scrub or pin, setting end may not visibly change normal tween playback.

14. Start vs end mental model

SCROLL ↓STARTACTIVE RANGEEND
Later lessons will connect this range to scrub, pin and playback actions.

15. Animate a heading on scroll

GSAP ScrollTrigger

Animation Begins When You Reach It

The section is the trigger while its heading is the target.

16. Animate a paragraph on scroll

Smaller movement can suit body copy because it supports reading without drawing excessive attention. Context still determines the right choice.

17. Animate an image on scroll

18. Text + image section

Scroll-driven design

Reveal related content as one section

The text and visual use one section trigger with modest, responsive motion.

Explore services

19. Animate multiple cards

Web DevelopmentModern digital execution
AI SolutionsModern digital execution
SEO OptimizationModern digital execution
UI/UX DesignModern digital execution

20. ScrollTrigger + stagger

SCROLLTRIGGER ACTIVATESSTAGGER TWEEN
Card 1   Card 2   Card 3   Card 4
ScrollTrigger activates the group; stagger distributes its targets.

21. One trigger vs trigger per card

Use a group trigger when cards form one visual unit. Use individual triggers when items are far apart or should reveal independently. Neither approach is always better.

22. Individual card triggers

document.querySelectorAll(".individual-scroll-card")
  .forEach((card) => {
    gsap.from(card, {
      y: 40, opacity: 0, duration: 0.7,
      scrollTrigger: { trigger: card, start: "top 85%" }
    });
  });

23. Group trigger vs individual triggers

GROUP[ CARD ][ CARD ][ CARD ]↑ ONE TRIGGER
INDIVIDUAL[ CARD ] ← Trigger[ CARD ] ← Trigger[ CARD ] ← Trigger

24. ScrollTrigger with gsap.to()

gsap.to(".scroll-to-box", {
  x: 120, rotation: 8, duration: 1,
  scrollTrigger: { trigger: ".scroll-to-demo", start: "top 80%" }
});

ScrollTrigger can activate the destination animation introduced in gsap.to().

25. ScrollTrigger with gsap.from()

from() is convenient for entrance animation because the document’s natural styling remains the destination.

26. ScrollTrigger with gsap.fromTo()

gsap.fromTo(".box",
  { x: -70, opacity: 0 },
  { x: 0, opacity: 1, duration: 0.8,
    scrollTrigger: { trigger: ".demo", start: "top 80%" }
  }
);

With fromTo(), ScrollTrigger belongs in the destination vars object.

27. ScrollTrigger + timeline

const tl = gsap.timeline({
  scrollTrigger: { trigger: ".scroll-section", start: "top 75%" }
});

tl.from(".label", { y: 15, opacity: 0 })
  .from(".title", { y: 40, opacity: 0 })
  .from(".card", { y: 30, opacity: 0, stagger: 0.1 });

One trigger can activate the complete timeline.

28. ScrollTrigger + timeline mental model

SCROLLTRIGGER REACHEDTIMELINE STARTS
Label → Title → Text → Cards → CTA

29. Practical services section

NavTechSolution

Our Digital Services

Modern development and digital solutions for growing businesses.

Web DevelopmentEducational demo card
AI SolutionsEducational demo card
SEOEducational demo card
UI/UXEducational demo card

30. Practical about section

About visual
Our approach

Strategy meets implementation

Coordinate a visual, heading, paragraph and related feature items with one timeline.

AccessibleResponsiveMaintainable

31. Practical stats section

FastPerformance
ModernTechnology
ResponsiveDesign
AIIntegration

32. Portfolio grid reveal

Project conceptWeb Platform
Project conceptAI Dashboard
Project conceptBusiness Website
Project conceptBooking Interface
Project conceptAnalytics UI
Project conceptMarketing Site

33. Trigger different directions

From left
From below
From right

34. ScrollTrigger and opacity

A simple fade can be appropriate. ScrollTrigger does not require large movement.

35. ScrollTrigger and scale

Subtle scale: 0.94 plus opacity can add depth without making the layout feel unstable.

36. Replay behavior: an important concept

A basic scroll-triggered entrance does not necessarily replay every time users move up and down as beginners may expect. A later lesson will teach detailed enter/leave playback control.

BEFORE STARTWaiting
ENTERPlay tween
AFTER STARTCompleted state
A standard entrance plays when its start is crossed; replay behavior is a separate choice.

37. Basic once concept

GSAP 3 ScrollTrigger supports once: true when an entrance should activate once and then remove its trigger.

38. Avoid animating everything

Prioritize section headings, meaningful groups, major visuals and content transitions. Do not force every paragraph, icon or tiny label to wait without a design reason.

39. Common ScrollTrigger mistakes

1. Forgetting to load the plugin
2. Forgetting plugin registration
3. Mixing incompatible GSAP versions
4. Using the wrong trigger
5. Confusing target and trigger
6. Choosing an unreachable start
7. Leaving markers enabled
8. Creating a trigger for every tiny item
9. Stacking triggers during rebuilds
10. Not killing a demo-owned trigger
11. Using excessive motion distance
12. Creating mobile horizontal overflow
13. Hiding content when JavaScript fails
14. Ignoring reduced motion
15. Expecting end to change basic playback
16. Assuming ScrollTrigger means scrub
17. Assuming ScrollTrigger means pin
18. Using huge text movement
19. Loading GSAP or the plugin twice
20. Ignoring layout changes

40. Debugging checklist

1GSAP loaded
2ScrollTrigger loaded
3Plugin registered
4Target exists
5Trigger exists
6Start is reachable
7Console has no errors
8No conflicting inline styles
9Page has scroll space
10No duplicate triggers
11Temporary markers considered

41. ScrollTrigger.refresh() concept

ScrollTrigger calculates positions from layout. Call ScrollTrigger.refresh() deliberately after significant custom layout changes—not continuously or on every scroll.

1Layout changesImage · font · accordion
2Refresh positionsScrollTrigger.refresh()
3Accurate triggersStart lines match layout
Refresh is a deliberate recalculation after meaningful geometry changes.

42. Images and layout changes

Images, fonts, accordions and inserted content can move positions. Provide image dimensions and refresh only when a real dynamic layout change requires it.

43. Performance

Prefer practical transform and opacity animation, avoid hundreds of unnecessary triggers and test complex effects on real mobile devices. No property is a substitute for measurement.

TRANSFORMx · y · scalePrefer for movement
OPACITY0 → 1Pair with subtle motion
MEASUREReal devicesValidate the result
A practical performance path: choose suitable properties, limit trigger count and measure.

44. Accessibility

const reduceMotion = window.matchMedia(
  "(prefers-reduced-motion: reduce)"
).matches;

Reduced-motion users receive the complete content without scroll entrances in this implementation.

STANDARD MOTIONScroll → RevealShort, meaningful entrance
OR
REDUCED MOTIONContent visibleNo required animation
The same content and reading order remain available in both preference modes.

45. Progressive enhancement

HTML content exists normally. JavaScript enhances it with motion; CSS does not permanently hide essential information.

46. Mobile ScrollTrigger

Use container-safe motion and reduce horizontal distances on narrow screens. Test 320, 375, 768, 1024 and 1440 pixel layouts.

320–480Short distanceSingle column
768–1024Balanced motionAdaptive grid
1440+More spaceContained movement
Responsive motion changes distance and layout while preserving the same content hierarchy.

47. Main ScrollTrigger lab

NavTechSolution

Scroll-Driven Experiences

Create modern web interactions that activate as users explore the page.

Trigger
Timeline
Stagger
Easing

Waiting for lab top to reach viewport 75%

START 75%LAB SECTION
LAB TOP MEETS 75%TIMELINELabel · Title · Text · Cards · CTA

48. Lab visualization

The adjacent viewport diagram explains the actual trigger used by the main timeline without turning on production markers.

49. Start position playground

The earlier playground changes its viewport line and demonstrates how later or earlier positions affect activation. It rebuilds only its own conceptual state.

50. Trigger selection playground

SECTION WRAPPER

Heading

Card target

Current trigger: Section wrapper

51. Mini project

NavTechSolution

Build Scroll Animations

Trigger coordinated GSAP animations as content enters the viewport.

Trigger
Start
Timeline
Show suggested solution
const miniTl = gsap.timeline({
  scrollTrigger: { trigger: miniProject, start: "top 80%" }
});
miniTl.from(label, { y: 15, opacity: 0 })
  .from(title, { y: 35, opacity: 0 }, "-=0.1")
  .from(text, { y: 20, opacity: 0 }, "-=0.3")
  .from(cards, { y: 30, opacity: 0, stagger: 0.1 }, "-=0.2");

52. Quick reference

ConceptExamplePurpose
Registergsap.registerPlugin(ScrollTrigger)Register plugin
ScrollTriggerscrollTrigger: {...}Attach scroll behavior
Triggertrigger: ".section"Positioning element
Startstart: "top 80%"Activation point
Endend: "bottom 20%"Active range end
Markersmarkers: trueDebug positions
Onceonce: trueOne-time activation
Timelinegsap.timeline({ scrollTrigger: {...} })Trigger a sequence
RefreshScrollTrigger.refresh()Recalculate when necessary

53. Cheat sheet graphic

1. LOADGSAP + ScrollTrigger
2. REGISTERgsap.registerPlugin()
3. ANIMATEgsap.from(...)
4. ADD TRIGGERtrigger + start
5. SCROLLTrigger reached → motion

54. Final mental model

USER SCROLLSSCROLLTRIGGER · trigger · start · endGSAP · from · to · fromTo · timelineVISIBLE MOTIONStagger distributes targets · Easing shapes motion · Position parameters overlap timeline steps

55. Continue with Blog #15

We now understand trigger and a basic start: "top 80%". Continue with GSAP ScrollTrigger Start & End to unpack position combinations, offsets and precise active ranges.

Continue the GSAP series

Connect ScrollTrigger with gsap.to(), gsap.from(), gsap.fromTo(), stagger, easing, timelines, timeline controls, position parameters and timeline + stagger.

Frequently asked questions

What is GSAP ScrollTrigger?

ScrollTrigger is a GSAP plugin that activates animations and interactions according to scroll position.

Is ScrollTrigger part of GSAP?

Yes. It is an official GSAP plugin loaded separately from the core library and registered before use.

How do I register ScrollTrigger?

After loading GSAP and ScrollTrigger, call gsap.registerPlugin(ScrollTrigger).

What does trigger mean in ScrollTrigger?

The trigger is the element ScrollTrigger watches when calculating activation positions.

What does start: "top 80%" mean?

It activates when the trigger element’s top reaches the point 80% down the viewport.

What is the difference between trigger and animation target?

The target is animated by GSAP; the trigger is watched by ScrollTrigger. They may be the same element or different elements.

How do I animate cards when scrolling?

Create a tween for the card collection, add stagger if needed, and use the grid or section as its ScrollTrigger trigger.

Can ScrollTrigger work with GSAP timelines?

Yes. Put a scrollTrigger object in the timeline configuration to activate the complete sequence.

Can I use stagger with ScrollTrigger?

Yes. ScrollTrigger activates the group tween and stagger distributes the starts inside that group.

What are ScrollTrigger markers?

Markers are development aids that display trigger and scroller start/end positions.

Does ScrollTrigger work on mobile?

Yes, but motion distance, layout, content height and reduced-motion preferences should be tested on real devices.

Can I use GSAP ScrollTrigger on a PHP website?

Yes. PHP renders the page and ScrollTrigger runs in the browser like any other JavaScript library.

How do I make ScrollTrigger animations accessible?

Respect prefers-reduced-motion and keep content usable, visible and logically ordered without animation.

Why is my ScrollTrigger animation not working?

Check that GSAP and ScrollTrigger loaded, the plugin is registered, selectors exist and the start position is reachable.