src/slidy.js
function slide(direction) {
    const movement = direction === true ? 1 : -1
    let duration = slideSpeed

    // calculate the nextIndex according to the movement
    let nextIndex = index + 1 * movement

    // nextIndex should be between 0 and items minus 1
    nextIndex = clampNumber(nextIndex, 0, items - 1)

    // if the nextIndex and the current is the same, we don't need to do the slide
    if (nextIndex === index) return

    // if the nextIndex is possible according to number of items, then use it
    if (nextIndex <= items) {
      // execute the callback from the options before sliding
      doBeforeSlide({currentSlide: index, nextSlide: nextIndex})
      // execute the internal callback
      direction ? onNext(nextIndex) : onPrev(nextIndex)
      index = nextIndex
    }

    // translate to the next index by a defined duration and ease function
    _translate(duration, ease)

    // execute the callback from the options after sliding
    slidesDOMEl.addEventListener(TRANSITION_END, function cb(e) {
      doAfterSlide({currentSlide: index})
      e.currentTarget.removeEventListener(e.type, cb)
    })
  }
function slide(direction) {
    const movement = direction === true ? 1 : -1
    let duration = slideSpeed

    // calculate the nextIndex according to the movement
    let nextIndex = index + 1 * movement

    // nextIndex should be between 0 and items minus 1
    nextIndex = clampNumber(nextIndex, 0, items - 1)

    // if the nextIndex and the current is the same, we don't need to do the slide
    if (nextIndex === index) return

    // if the nextIndex is possible according to number of items, then use it
    if (nextIndex <= items) {
      // execute the callback from the options before sliding
      doBeforeSlide({currentSlide: index, nextSlide: nextIndex})
      // execute the internal callback
      direction ? onNext(nextIndex) : onPrev(nextIndex)
      index = nextIndex
    }

    // translate to the next index by a defined duration and ease function
    _translate(duration, ease)

    // execute the callback from the options after sliding
    slidesDOMEl.addEventListener(TRANSITION_END, function cb(e) {
      doAfterSlide({currentSlide: index})
      e.currentTarget.removeEventListener(e.type, cb)
    })
  }
function slide ( direction ) { const movement = direction === true ? 1 : - 1 let duration = slideSpeed // calculate the nextIndex according to the movement let nextIndex = index + 1 * movement // nextIndex should be between 0 and items minus 1 nextIndex = clampNumber ( nextIndex , 0 , items - 1 ) // if the nextIndex and the current is the same, we don't need to do the slide if ( nextIndex === index ) return // if the nextIndex is possible according to number of items, then use it if ( nextIndex <= items ) { // execute the callback from the options before sliding doBeforeSlide ( { currentSlide : index , nextSlide : nextIndex } ) // execute the internal callback direction ? onNext ( nextIndex ) : onPrev ( nextIndex ) index = nextIndex } // translate to the next index by a defined duration and ease function _translate ( duration , ease ) // execute the callback from the options after sliding slidesDOMEl . addEventListener ( TRANSITION_END , function cb ( e ) { doAfterSlide ( { currentSlide : index } ) e . currentTarget . removeEventListener ( e . type , cb ) } ) }
slide function called by prev, next & touchend

determine nextIndex and slide to next postion
under restrictions of the defined options

@direction  {boolean} 'true' for right, 'false' for left
slide function called by prev next & touchend