onscroll(top) {
    if (this.paused) return;

    const marginTop = this.getMarginTop();
    const viewportHeight = $(window).height() - marginTop;
    const viewportTop = top + marginTop;
    const loadAheadDistance = 300;

    if (this.visibleStart > 0) {
      const $item = this.$('.PostStream-item[data-index=' + this.visibleStart + ']');

      if ($item.length && $item.offset().top > viewportTop - loadAheadDistance) {
        this.loadPrevious();
      }
    }

    if (this.visibleEnd < this.count()) {
      const $item = this.$('.PostStream-item[data-index=' + (this.visibleEnd - 1) + ']');

      if ($item.length && $item.offset().top + $item.outerHeight(true) < viewportTop + viewportHeight + loadAheadDistance) {
        this.loadNext();
      }
    }

    // Throttle calculation of our position (start/end numbers of posts in the
    // viewport) to 100ms.
    clearTimeout(this.calculatePositionTimeout);
    this.calculatePositionTimeout = setTimeout(this.calculatePosition.bind(this), 100);
  }
/**
   * When the window is scrolled, check if either extreme of the post stream is
   * in the viewport, and if so, trigger loading the next/previous page.
   *
   * @param {Integer} top
   */
When the window is scrolled, check if either extreme of the post stream is
in the viewport, and if so, trigger loading the next/previous page.

@param {Integer} top
When the window is scrolled check if either extreme of the post stream is in the viewport and if so trigger loading the next / previous page . @param { Integer } top
onscroll(top) {
    if (this.paused) return;
    const marginTop = this.getMarginTop();
    const viewportHeight = $(window).height() - marginTop;
    const viewportTop = top + marginTop;
    const loadAheadDistance = 300;
    if (this.visibleStart > 0) {
      const $item = this.$('.PostStream-item[data-index=' + this.visibleStart + ']');
      if ($item.length && $item.offset().top > viewportTop - loadAheadDistance) {
        this.loadPrevious();
      }
    }
    if (this.visibleEnd < this.count()) {
      const $item = this.$('.PostStream-item[data-index=' + (this.visibleEnd - 1) + ']');
      if ($item.length && $item.offset().top + $item.outerHeight(true) < viewportTop + viewportHeight + loadAheadDistance) {
        this.loadNext();
      }
    }
    clearTimeout(this.calculatePositionTimeout);
    this.calculatePositionTimeout = setTimeout(this.calculatePosition.bind(this), 100);
  }
onscroll ( top ) { if ( this . paused ) return ; const marginTop = this . getMarginTop ( ) ; const viewportHeight = $ ( window ) . height ( ) - marginTop ; const viewportTop = top + marginTop ; const loadAheadDistance = 300 ; if ( this . visibleStart > 0 ) { const $item = this . $ ( '.PostStream-item[data-index=' + this . visibleStart + ']' ) ; if ( $item . length && $item . offset ( ) . top > viewportTop - loadAheadDistance ) { this . loadPrevious ( ) ; } } if ( this . visibleEnd < this . count ( ) ) { const $item = this . $ ( '.PostStream-item[data-index=' + ( this . visibleEnd - 1 ) + ']' ) ; if ( $item . length && $item . offset ( ) . top + $item . outerHeight ( true ) < viewportTop + viewportHeight + loadAheadDistance ) { this . loadNext ( ) ; } } clearTimeout ( this . calculatePositionTimeout ) ; this . calculatePositionTimeout = setTimeout ( this . calculatePosition . bind ( this ) , 100 ) ; }
When the window is scrolled, check if either extreme of the post stream is
 in the viewport, and if so, trigger loading the next/previous page.
When the window is scrolled check if either extreme of the post stream is in the viewport and if so trigger loading the next / previous page .
// Throttle calculation of our position (start/end numbers of posts in the // viewport) to 100ms.