update(scrollTop) {
    const stream = this.props.stream;

    const marginTop = stream.getMarginTop();
    const viewportTop = scrollTop + marginTop;
    const viewportHeight = $(window).height() - marginTop;

    // Before looping through all of the posts, we reset the scrollbar
    // properties to a 'default' state. These values reflect what would be
    // seen if the browser were scrolled right up to the top of the page,
    // and the viewport had a height of 0.
    const $items = stream.$('> .PostStream-item[data-index]');
    let index = $items.first().data('index') || 0;
    let visible = 0;
    let period = '';

    // Now loop through each of the items in the discussion. An 'item' is
    // either a single post or a 'gap' of one or more posts that haven't
    // been loaded yet.
    $items.each(function() {
      const $this = $(this);
      const top = $this.offset().top;
      const height = $this.outerHeight(true);

      // If this item is above the top of the viewport, skip to the next
      // one. If it's below the bottom of the viewport, break out of the
      // loop.
      if (top + height < viewportTop) {
        return true;
      }
      if (top > viewportTop + viewportHeight) {
        return false;
      }

      // Work out how many pixels of this item are visible inside the viewport.
      // Then add the proportion of this item's total height to the index.
      const visibleTop = Math.max(0, viewportTop - top);
      const visibleBottom = Math.min(height, viewportTop + viewportHeight - top);
      const visiblePost = visibleBottom - visibleTop;

      if (top <= viewportTop) {
        index = parseFloat($this.data('index')) + visibleTop / height;
      }

      if (visiblePost > 0) {
        visible += visiblePost / height;
      }

      // If this item has a time associated with it, then set the
      // scrollbar's current period to a formatted version of this time.
      const time = $this.data('time');
      if (time) period = time;
    });

    this.index = index;
    this.visible = visible;
    this.description = period ? moment(period).format('MMMM YYYY') : '';
  }
/**
   * Update the index/visible/description properties according to the window's
   * current scroll position.
   *
   * @param {Integer} scrollTop
   */
Update the index/visible/description properties according to the window's
current scroll position.

@param {Integer} scrollTop
Update the index / visible / description properties according to the window ' s current scroll position . @param { Integer } scrollTop
update(scrollTop) {
    const stream = this.props.stream;
    const marginTop = stream.getMarginTop();
    const viewportTop = scrollTop + marginTop;
    const viewportHeight = $(window).height() - marginTop;
    const $items = stream.$('> .PostStream-item[data-index]');
    let index = $items.first().data('index') || 0;
    let visible = 0;
    let period = '';
    $items.each(function() {
      const $this = $(this);
      const top = $this.offset().top;
      const height = $this.outerHeight(true);
      if (top + height < viewportTop) {
        return true;
      }
      if (top > viewportTop + viewportHeight) {
        return false;
      }
      const visibleTop = Math.max(0, viewportTop - top);
      const visibleBottom = Math.min(height, viewportTop + viewportHeight - top);
      const visiblePost = visibleBottom - visibleTop;
      if (top <= viewportTop) {
        index = parseFloat($this.data('index')) + visibleTop / height;
      }
      if (visiblePost > 0) {
        visible += visiblePost / height;
      }
      const time = $this.data('time');
      if (time) period = time;
    });
    this.index = index;
    this.visible = visible;
    this.description = period ? moment(period).format('MMMM YYYY') : '';
  }
update ( scrollTop ) { const stream = this . props . stream ; const marginTop = stream . getMarginTop ( ) ; const viewportTop = scrollTop + marginTop ; const viewportHeight = $ ( window ) . height ( ) - marginTop ; const $items = stream . $ ( '> .PostStream-item[data-index]' ) ; let index = $items . first ( ) . data ( 'index' ) || 0 ; let visible = 0 ; let period = '' ; $items . each ( function ( ) { const $this = $ ( this ) ; const top = $this . offset ( ) . top ; const height = $this . outerHeight ( true ) ; if ( top + height < viewportTop ) { return true ; } if ( top > viewportTop + viewportHeight ) { return false ; } const visibleTop = Math . max ( 0 , viewportTop - top ) ; const visibleBottom = Math . min ( height , viewportTop + viewportHeight - top ) ; const visiblePost = visibleBottom - visibleTop ; if ( top <= viewportTop ) { index = parseFloat ( $this . data ( 'index' ) ) + visibleTop / height ; } if ( visiblePost > 0 ) { visible += visiblePost / height ; } const time = $this . data ( 'time' ) ; if ( time ) period = time ; } ) ; this . index = index ; this . visible = visible ; this . description = period ? moment ( period ) . format ( 'MMMM YYYY' ) : '' ; }
Update the index/visible/description properties according to the window's
 current scroll position.
Update the index / visible / description properties according to the window ' s current scroll position .
// Before looping through all of the posts, we reset the scrollbar // properties to a 'default' state. These values reflect what would be // seen if the browser were scrolled right up to the top of the page, // and the viewport had a height of 0. // Now loop through each of the items in the discussion. An 'item' is // either a single post or a 'gap' of one or more posts that haven't // been loaded yet. // If this item is above the top of the viewport, skip to the next // one. If it's below the bottom of the viewport, break out of the // loop. // Work out how many pixels of this item are visible inside the viewport. // Then add the proportion of this item's total height to the index. // If this item has a time associated with it, then set the // scrollbar's current period to a formatted version of this time.