extensions/amp-carousel/0.1/slidescroll.js
/**
   * Animate and snap to the correct slide for a given scrollLeft.
   * @param {number} currentScrollLeft scrollLeft value of the slides container.
   * @param {number=} opt_forceDir if a valid direction is given force it to
   *    move 1 slide in that direction.
   * @return {!Promise}
   */
Animate and snap to the correct slide for a given scrollLeft.
@param {number} currentScrollLeft scrollLeft value of the slides container.
@param {number=} opt_forceDir if a valid direction is given force it to
move 1 slide in that direction.
@return {!Promise}
Animate and snap to the correct slide for a given scrollLeft . @param { number } currentScrollLeft scrollLeft value of the slides container . @param { number = } opt_forceDir if a valid direction is given force it to move 1 slide in that direction . @return { !Promise }
customSnap_(currentScrollLeft, opt_forceDir) {
    this.snappingInProgress_ = true;
    const newIndex = this.getNextSlideIndex_(currentScrollLeft);
    let toScrollLeft;
    let diff = newIndex - this.slideIndex_;
    const hasPrev = this.hasPrev();
    if (diff == 0 && (opt_forceDir == 1 || opt_forceDir == -1)) {
      diff = opt_forceDir;
    }
    if (diff == 0) {
      toScrollLeft = hasPrev ? this.slideWidth_ : 0;
    } else if (diff == 1 ||
        (diff != -1 && diff == -1 * (this.noOfSlides_ - 1))) {
      toScrollLeft = hasPrev ? this.slideWidth_ * 2 : this.slideWidth_;
    } else if (diff == -1 || diff == this.noOfSlides_ - 1) {
      toScrollLeft = 0;
    }
    return this.animateScrollLeft_(currentScrollLeft, toScrollLeft).then(() => {
      this.updateOnScroll_(toScrollLeft);
    });
  }
customSnap_ ( currentScrollLeft , opt_forceDir ) { this . snappingInProgress_ = true ; const newIndex = this . getNextSlideIndex_ ( currentScrollLeft ) ; let toScrollLeft ; let diff = newIndex - this . slideIndex_ ; const hasPrev = this . hasPrev ( ) ; if ( diff == 0 && ( opt_forceDir == 1 || opt_forceDir == - 1 ) ) { diff = opt_forceDir ; } if ( diff == 0 ) { toScrollLeft = hasPrev ? this . slideWidth_ : 0 ; } else if ( diff == 1 || ( diff != - 1 && diff == - 1 * ( this . noOfSlides_ - 1 ) ) ) { toScrollLeft = hasPrev ? this . slideWidth_ * 2 : this . slideWidth_ ; } else if ( diff == - 1 || diff == this . noOfSlides_ - 1 ) { toScrollLeft = 0 ; } return this . animateScrollLeft_ ( currentScrollLeft , toScrollLeft ) . then ( ( ) => { this . updateOnScroll_ ( toScrollLeft ) ; } ) ; }
Animate and snap to the correct slide for a given scrollLeft.
Animate and snap to the correct slide for a given scrollLeft .
// Snap and stay. // Move fwd. // Move backward.