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
Full-stack observability with actually useful AI | Grafana Cloud Icon
Full-stack observability with actually useful AI | Grafana Cloud

Our generous forever free tier includes the full platform, including the AI Assistant, for 3 users with 10k metrics, 50GB logs, and 50GB traces.

Built on open standards like Prometheus and OpenTelemetry, Grafana Cloud includes Kubernetes Monitoring, Application Observability, Incident Response, plus the AI-powered Grafana Assistant. Get started with our generous free tier today.
Create free account
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