extensions/amp-carousel/0.1/slidescroll.js
/**
   * Makes the slide corresponding to the given index and the slides surrounding
   *     it available for display.
   * @note Element must be laid out.
   * @param {number} newIndex Index of the slide to be displayed.
   * @return {boolean} true if the slide changed, otherwise false.
   * @private
   */
Makes the slide corresponding to the given index and the slides surrounding
it available for display.
@note Element must be laid out.
@param {number} newIndex Index of the slide to be displayed.
@return {boolean} true if the slide changed, otherwise false.
@private
Makes the slide corresponding to the given index and the slides surrounding it available for display . @note Element must be laid out . @param { number } newIndex Index of the slide to be displayed . @return { boolean } true if the slide changed otherwise false . @private
showSlide_(newIndex) {
    const noOfSlides_ = this.noOfSlides_;
    newIndex = dev().assertNumber(newIndex);
    if (newIndex < 0 ||
        newIndex >= noOfSlides_ ||
        this.slideIndex_ == newIndex) {
      return false;
    }
    const prevIndex = (newIndex - 1 >= 0) ? newIndex - 1 :
        (this.shouldLoop) ? noOfSlides_ - 1 : null;
    const nextIndex = (newIndex + 1 < noOfSlides_) ? newIndex + 1 :
        (this.shouldLoop) ? 0 : null;
    const showIndexArr = [];
    if (prevIndex != null) {
      showIndexArr.push(prevIndex);
    }
    showIndexArr.push(newIndex);
    if (nextIndex != null) {
      showIndexArr.push(nextIndex);
    }
    if (this.slideIndex_ !== null) {
      this.updateInViewport(this.slides_[
          dev().assertNumber(this.slideIndex_)], false);
    }
    const newSlideInView = this.slides_[newIndex];
    if (newSlideInView === undefined) {
      const error = new Error('Attempting to access a non-existant slide');
      error.args = {
        'index': newIndex,
        'noOfSlides': noOfSlides_,
      };
      dev().error(TAG, error);
      return false;
    }
    this.updateInViewport(newSlideInView, true);
    showIndexArr.forEach((showIndex, loopIndex) => {
      if (this.shouldLoop) {
        setStyle(this.slideWrappers_[showIndex], 'order', loopIndex + 1);
      }
      this.slideWrappers_[showIndex].classList.add(SHOWN_CSS_CLASS);
      if (showIndex == newIndex) {
        this.scheduleLayout(this.slides_[showIndex]);
        this.scheduleResume(this.slides_[showIndex]);
        this.slides_[showIndex].setAttribute('aria-hidden', 'false');
      } else {
        this.schedulePreload(this.slides_[showIndex]);
        this.slides_[showIndex].setAttribute('aria-hidden', 'true');
      }
    });
    this.slidesContainer_.scrollLeft =
        this.getScrollLeftForIndex_(newIndex);
    this.triggerAnalyticsEvent_(newIndex);
    this.slideIndex_ = newIndex;
    this.hideRestOfTheSlides_(showIndexArr);
    this.setControlsState();
    return true;
  }
showSlide_ ( newIndex ) { const noOfSlides_ = this . noOfSlides_ ; newIndex = dev ( ) . assertNumber ( newIndex ) ; if ( newIndex < 0 || newIndex >= noOfSlides_ || this . slideIndex_ == newIndex ) { return false ; } const prevIndex = ( newIndex - 1 >= 0 ) ? newIndex - 1 : ( this . shouldLoop ) ? noOfSlides_ - 1 : null ; const nextIndex = ( newIndex + 1 < noOfSlides_ ) ? newIndex + 1 : ( this . shouldLoop ) ? 0 : null ; const showIndexArr = [ ] ; if ( prevIndex != null ) { showIndexArr . push ( prevIndex ) ; } showIndexArr . push ( newIndex ) ; if ( nextIndex != null ) { showIndexArr . push ( nextIndex ) ; } if ( this . slideIndex_ !== null ) { this . updateInViewport ( this . slides_ [ dev ( ) . assertNumber ( this . slideIndex_ ) ] , false ) ; } const newSlideInView = this . slides_ [ newIndex ] ; if ( newSlideInView === undefined ) { const error = new Error ( 'Attempting to access a non-existant slide' ) ; error . args = { 'index' : newIndex , 'noOfSlides' : noOfSlides_ , } ; dev ( ) . error ( TAG , error ) ; return false ; } this . updateInViewport ( newSlideInView , true ) ; showIndexArr . forEach ( ( showIndex , loopIndex ) => { if ( this . shouldLoop ) { setStyle ( this . slideWrappers_ [ showIndex ] , 'order' , loopIndex + 1 ) ; } this . slideWrappers_ [ showIndex ] . classList . add ( SHOWN_CSS_CLASS ) ; if ( showIndex == newIndex ) { this . scheduleLayout ( this . slides_ [ showIndex ] ) ; this . scheduleResume ( this . slides_ [ showIndex ] ) ; this . slides_ [ showIndex ] . setAttribute ( 'aria-hidden' , 'false' ) ; } else { this . schedulePreload ( this . slides_ [ showIndex ] ) ; this . slides_ [ showIndex ] . setAttribute ( 'aria-hidden' , 'true' ) ; } } ) ; this . slidesContainer_ . scrollLeft = this . getScrollLeftForIndex_ ( newIndex ) ; this . triggerAnalyticsEvent_ ( newIndex ) ; this . slideIndex_ = newIndex ; this . hideRestOfTheSlides_ ( showIndexArr ) ; this . setControlsState ( ) ; return true ; }
Makes the slide corresponding to the given index and the slides surrounding
     it available for display.
Makes the slide corresponding to the given index and the slides surrounding it available for display .
/*OK*/