Capítulo 373 de 411

Chapter 373: ScrollTrigger.sort

Core Idea

Sorts the internal Array of ScrollTrigger instances to control the order in which they refresh() (calculate their start/end values).

Key Concepts

  • func: Function

Code Examples

ScrollTrigger.create({
  refreshPriority: -1, // lower priority makes it happen later in the refresh() calculations
  ...
});
ScrollTrigger.create({
  ... // if no refreshPriority is defined, it defaults to 0
});
gsap.to(".class", { // works with tweens/timelines too
  opacity: 1,
  scrollTrigger: {
    refreshPriority: 3, // a higher number makes it happen earlier in the refresh() calculations
    ...
  }
});

ScrollTrigger.sort(); // use the defaults (typically best)

// or use a custom function...
ScrollTrigger.sort((a, b) => a.start - b.start);
  • What it demonstrates: typical usage of ScrollTrigger.sort in a GSAP animation.

Key Takeaways

  1. func: Function

Connects To