extensions/amp-position-observer/0.1/amp-position-observer.js
/**
   * Calculates the current scroll progress as a percentage.
   * Scroll progress is a decimal between 0-1 and shows progress between
   * enter and exit, considering ratio and margins.
   * When a scene becomes visible (enters based on ratio and margins), from
   * bottom, progress is 0 as it moves toward the top, progress increases until
   * it becomes exists with 1 from the top.
   *
   * Entering from the top gives the reverse values, 1 at enter, 0 at exit.
   * @param {?../../../src/layout-rect.LayoutRectDef} positionRect position rect as returned by position observer
   * @param {!../../../src/layout-rect.LayoutRectDef} adjustedViewportRect viewport rect adjusted for margins.
   * @private
   */
Calculates the current scroll progress as a percentage.
Scroll progress is a decimal between 0-1 and shows progress between
enter and exit, considering ratio and margins.
When a scene becomes visible (enters based on ratio and margins), from
bottom, progress is 0 as it moves toward the top, progress increases until
it becomes exists with 1 from the top.

Entering from the top gives the reverse values, 1 at enter, 0 at exit.
Calculates the current scroll progress as a percentage . Scroll progress is a decimal between 0 - 1 and shows progress between enter and exit considering ratio and margins . When a scene becomes visible ( enters based on ratio and margins ) from bottom progress is 0 as it moves toward the top progress increases until it becomes exists with 1 from the top . Entering from the top gives the reverse values 1 at enter 0 at exit .
updateScrollProgress_(positionRect, adjustedViewportRect) {
    if (!positionRect) {
      return;
    }
    const totalProgressOffset = (positionRect.height * this.bottomRatio_) +
        (positionRect.height * this.topRatio_);
    const totalProgress = adjustedViewportRect.height +
        positionRect.height - totalProgressOffset;
    const topOffset = Math.abs(
        positionRect.top - this.resolvedTopMargin_ -
        (adjustedViewportRect.height -
            (positionRect.height * this.bottomRatio_)
        )
      );
    this.scrollProgress_ = topOffset / totalProgress;
  }
updateScrollProgress_ ( positionRect , adjustedViewportRect ) { if ( ! positionRect ) { return ; } const totalProgressOffset = ( positionRect . height * this . bottomRatio_ ) + ( positionRect . height * this . topRatio_ ) ; const totalProgress = adjustedViewportRect . height + positionRect . height - totalProgressOffset ; const topOffset = Math . abs ( positionRect . top - this . resolvedTopMargin_ - ( adjustedViewportRect . height - ( positionRect . height * this . bottomRatio_ ) ) ) ; this . scrollProgress_ = topOffset / totalProgress ; }
Calculates the current scroll progress as a percentage.
Calculates the current scroll progress as a percentage .