swiper
Version:
Most modern mobile touch slider and framework with hardware accelerated transitions
30 lines (26 loc) • 765 B
JavaScript
export default function (runCallbacks = true, direction) {
const swiper = this;
const { activeIndex, previousIndex, params } = swiper;
swiper.animating = false;
if (params.cssMode) return;
swiper.setTransition(0);
let dir = direction;
if (!dir) {
if (activeIndex > previousIndex) dir = 'next';
else if (activeIndex < previousIndex) dir = 'prev';
else dir = 'reset';
}
swiper.emit('transitionEnd');
if (runCallbacks && activeIndex !== previousIndex) {
if (dir === 'reset') {
swiper.emit('slideResetTransitionEnd');
return;
}
swiper.emit('slideChangeTransitionEnd');
if (dir === 'next') {
swiper.emit('slideNextTransitionEnd');
} else {
swiper.emit('slidePrevTransitionEnd');
}
}
}