Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

Get Started with ScrollTrigger in 3 Easy Steps


| GreenSock
12223

This is a guest post from one of the best teachers of GSAP, Carl Schooff, also known as SnorklTV. If you're new to GSAP or just looking to learn about the GSAP 3 syntax, his video courses are second to none!

I can't tell you how many hundred's of questions I've seen in the GreenSock forums about controlling GSAP animations on scroll. I'm so happy there is finally a genuine GreenSock tool to power the future of scroll-driven animations.

Before I get into the specifics, it's worth a moment of time to honor those that got us here.

A short history of Scroll-driven Animations

John Polacek paved the way in 2013 with Superscrollorama, a jQuery plugin that used GSAP under the hood. Many amazing sites were created with this highly-acclaimed, ground-breaking, and trend-setting tool.

In 2014 Jan Paepke took the reins and did a complete re-write and SuperScrollarama became ScrollMagic. ScrollMagic was hugely successful as it offered a slew of new features. Excellent demo files made the tool easy for beginners to understand. Awards sites exploded with many clever effects made with the ScrollMagic and GSAP combo.

However, as with many solo-led open source projects, it's popularity created a hefty support burden that couldn't be managed.

As issues went unanswered in the ScrollMagic repo, more users found their way to the GreenSock forums asking for support on a product GreenSock didn't create or have any way of fixing.

ScrollTrigger is born

On June 1st, 2020, GreenSock released ScrollTrigger to a sold out audience via a historic YouTube Premiere.

ScrollTrigger was built with a totally fresh perspective on how GreenSock animations should be controlled via scroll. Not only does the API offer more features than it's predecessors, but it has a strong focus on performance which really shines in this "mobile-first" world. And as you can expect with any GreenSock product support is phenomenal.

For a full list of features, you'll need to check out GreenSock's ScrollTrigger API Docs, but my job here is to get you up and running quickly... so let's go!

Watch the Video

This video is from my course GSAP 3 Express. I've got over 6 hours of training and loads of exclusive demos to help you master the GreenSock Animation Platform from the ground up at creativeCodingClub.com

As always, I load my videos up with info so that I don't have to write a ton of stuff, but here are some key points.

Get ScrollTrigger and GSAP

ScrollTrigger is hosted on a CDN along with GSAP. Just use the script tags below to load it into your page.

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/ScrollTrigger.min.js"></script>	

Register ScrollTrigger

It's recommended to register ScrollTrigger in your JavaScript to avoid tree-shaking with build tools.

gsap.registerPlugin(ScrollTrigger);

You can get recent CDN Urls from the GSAP Overview in the docs.

For use with npm or more advanced build tools check out the GSAP installation videos.

Super Basic Demo with a Single Tween

The animation is super slow so that you can see how the animation reacts to entering and leaving the scroller-start and scroller-end positions.

Control a Timeline with ScrollTrigger

GreenSock's Toggle Action Demo

In the video I explained how toggleActions work and how important they are. For each toggle event (onEnter, onLeave, onEnterBack, onLeaveBack) you can assign an action (play, pause, restart, reset, resume, complete, reverse, none). You'll assign a toggleAction via a 4-part string like "restart pause resume reverse".

The best way to understand how they work is to play with the values in the demos above and study the demo below.

I'm hoping these resources help get you up and running quickly. For more inspiration check GreenSock's massive collection of ScrollTrigger Demos.

What's next?

I've only scratched the surface of what ScrollTrigger can do. I'll definitely be creating more training on this awesome tool.

If you need help learning GSAP and want to take your skills to the next level check out my courses at CreativeCodingClub.com.

Edited by GreenSock

  • Thanks 1

Get an all-access pass to premium plugins, offers, and more!

Join the Club

Cook up some delightful animation today with a generous dose of GSAP.

- Team GreenSock


User Feedback

Recommended Comments

There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×