swiper
Version:
Most modern mobile touch slider and framework with hardware accelerated transitions
20 lines (15 loc) • 673 B
JavaScript
/* eslint no-unused-vars: "off" */
export default function (speed = this.params.speed, runCallbacks = true, internal) {
const swiper = this;
let index = swiper.activeIndex;
const snapIndex = Math.floor(index / swiper.params.slidesPerGroup);
if (snapIndex < swiper.snapGrid.length - 1) {
const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
const currentSnap = swiper.snapGrid[snapIndex];
const nextSnap = swiper.snapGrid[snapIndex + 1];
if ((translate - currentSnap) > (nextSnap - currentSnap) / 2) {
index = swiper.params.slidesPerGroup;
}
}
return swiper.slideTo(index, speed, runCallbacks, internal);
}