Capítulo 338 de 411

Chapter 338: .getVelocity

Core Idea

Gets the scroll velocity in pixels-per-second

Code Examples

ScrollTrigger.create({
  trigger: ".trigger",
  start: "top center",
  end: "+=500",
  onUpdate: (self) => console.log("velocity:", self.getVelocity()),
});
  • What it demonstrates: typical usage of .getVelocity in a GSAP animation.

Key Takeaways

  1. Gets the scroll velocity in pixels-per-second