ScrollTrigger is a plugin from GSAP (GreenSock Animation Platform) that enables smooth and precise scrolling-based animations. It allows you to trigger animations based on the user's scroll position, providing dynamic and interactive visual effects on your web pages.
Let’s consider a scenario:
You have three circles aligned in a row, each with its own animation. If all animations play simultaneously as soon as you scroll, the second circle's animation might not be visible if it is out of view.
To fix this, you want each animation to start only when its respective circle becomes visible on the screen.
While you could add a delay to stagger animations, this approach is unreliable because it doesn’t account for unpredictable user scrolling behavior.
This is where ScrollTrigger comes in. It ensures animations are triggered precisely when a user scrolls to the target element, providing a seamless experience.
Include the ScrollTrigger CDN after the GSAP CDN in your HTML file. This ensures that ScrollTrigger works alongside GSAP.
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>

Now, create an animation using GSAP and integrate ScrollTrigger.
⚠️ Important:
Always use camelCase for property names in GSAP animations. Incorrect casing will result in errors.