The most basic usage of ScrollTrigger is to trigger classes based on the current scroll position. E.g. when an element enters the viewport, fade it in. You can add custom offsets per element, or set offsets on the viewport (e.g. always trigger after the element reaches 20% of the viewport) When using the callbacks ScrollTrigger becomes really powerful. You can run custom code when an element enters/becomes visible, and even return Promises to halt the trigger if the callback fails. This makes lazy loading images very easy. The easiest way to start is to create a new instance and add some triggers to it, with all default values. This will toggle the 'visible' class when the element comes into the viewport and toggles the 'invisible' class when it scrolls out of the viewport. Adding callbacks / different classes can be done globally, this becomes the default for all triggers you add, or you can specify custom configuration when adding a trigger.

Features

  • Add some callbacks and custom classes
  • Execute callbacks on entering/leaving the viewport
  • Let your page react to scroll changes
  • The easiest way to start is to create a new instance and add some triggers to it
  • For more examples, checkout the /demo directory on GitHub
  • You can run custom code when an element enters/becomes visible

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow ScrollTrigger

ScrollTrigger Web Site

Other Useful Business Software
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of ScrollTrigger!

Additional Project Details

Operating Systems

Windows

Programming Language

JavaScript

Related Categories

JavaScript User Interface (UI) Software, JavaScript Design Software

Registered

2022-06-17