Capítulo 367 de 411

Chapter 367: ScrollTrigger.positionInViewport

Core Idea

Returns a normalized value representing the element's position in relation to the viewport where 0 is at the top of the viewport, 0.5 is in the center, and 1 is at the bottom. So, for example, if the top of the element is 80% down from the top of the viewport, the following code would return 0.8: ScrollTrigger.positionInViewport(element, "top");

Key Concepts

  • element: Element | String

  • referencePoint: String | Number

  • horizontal: Boolean

Code Examples

ScrollTrigger.positionInViewport(element);
  • What it demonstrates: typical usage of ScrollTrigger.positionInViewport in a GSAP animation.

Key Takeaways

  1. element: Element | String

  2. referencePoint: String | Number

  3. horizontal: Boolean

Connects To