calculatePosition() {
    const marginTop = this.getMarginTop();
    const $window = $(window);
    const viewportHeight = $window.height() - marginTop;
    const scrollTop = $window.scrollTop() + marginTop;
    let startNumber;
    let endNumber;

    this.$('.PostStream-item').each(function() {
      const $item = $(this);
      const top = $item.offset().top;
      const height = $item.outerHeight(true);

      if (top + height > scrollTop) {
        if (!startNumber) {
          startNumber = endNumber = $item.data('number');
        }

        if (top + height < scrollTop + viewportHeight) {
          if ($item.data('number')) {
            endNumber = $item.data('number');
          }
        } else return false;
      }
    });

    if (startNumber) {
      this.trigger('positionChanged', startNumber || 1, endNumber);
    }
  }
/**
   * Work out which posts (by number) are currently visible in the viewport, and
   * fire an event with the information.
   */
Work out which posts (by number) are currently visible in the viewport, and
fire an event with the information.
Work out which posts ( by number ) are currently visible in the viewport and fire an event with the information .
calculatePosition() {
    const marginTop = this.getMarginTop();
    const $window = $(window);
    const viewportHeight = $window.height() - marginTop;
    const scrollTop = $window.scrollTop() + marginTop;
    let startNumber;
    let endNumber;
    this.$('.PostStream-item').each(function() {
      const $item = $(this);
      const top = $item.offset().top;
      const height = $item.outerHeight(true);
      if (top + height > scrollTop) {
        if (!startNumber) {
          startNumber = endNumber = $item.data('number');
        }
        if (top + height < scrollTop + viewportHeight) {
          if ($item.data('number')) {
            endNumber = $item.data('number');
          }
        } else return false;
      }
    });
    if (startNumber) {
      this.trigger('positionChanged', startNumber || 1, endNumber);
    }
  }
calculatePosition ( ) { const marginTop = this . getMarginTop ( ) ; const $window = $ ( window ) ; const viewportHeight = $window . height ( ) - marginTop ; const scrollTop = $window . scrollTop ( ) + marginTop ; let startNumber ; let endNumber ; this . $ ( '.PostStream-item' ) . each ( function ( ) { const $item = $ ( this ) ; const top = $item . offset ( ) . top ; const height = $item . outerHeight ( true ) ; if ( top + height > scrollTop ) { if ( ! startNumber ) { startNumber = endNumber = $item . data ( 'number' ) ; } if ( top + height < scrollTop + viewportHeight ) { if ( $item . data ( 'number' ) ) { endNumber = $item . data ( 'number' ) ; } } else return false ; } } ) ; if ( startNumber ) { this . trigger ( 'positionChanged' , startNumber || 1 , endNumber ) ; } }
Work out which posts (by number) are currently visible in the viewport, and
 fire an event with the information.
Work out which posts ( by number ) are currently visible in the viewport and fire an event with the information .