swiper
Version:
Most modern mobile touch slider and framework with hardware accelerated transitions
31 lines (27 loc) • 782 B
JavaScript
export default function (runCallbacks = true, direction) {
const swiper = this;
const { activeIndex, params, previousIndex } = swiper;
if (params.cssMode) return;
if (params.autoHeight) {
swiper.updateAutoHeight();
}
let dir = direction;
if (!dir) {
if (activeIndex > previousIndex) dir = 'next';
else if (activeIndex < previousIndex) dir = 'prev';
else dir = 'reset';
}
swiper.emit('transitionStart');
if (runCallbacks && activeIndex !== previousIndex) {
if (dir === 'reset') {
swiper.emit('slideResetTransitionStart');
return;
}
swiper.emit('slideChangeTransitionStart');
if (dir === 'next') {
swiper.emit('slideNextTransitionStart');
} else {
swiper.emit('slidePrevTransitionStart');
}
}
}