22 lines
819 B
JavaScript
22 lines
819 B
JavaScript
import Swiper from 'swiper';
|
|
export const calcLoopedSlides = (slides, swiperParams) => {
|
|
let slidesPerViewParams = swiperParams.slidesPerView;
|
|
|
|
if (swiperParams.breakpoints) {
|
|
const breakpoint = Swiper.prototype.getBreakpoint(swiperParams.breakpoints);
|
|
const breakpointOnlyParams = breakpoint in swiperParams.breakpoints ? swiperParams.breakpoints[breakpoint] : undefined;
|
|
|
|
if (breakpointOnlyParams && breakpointOnlyParams.slidesPerView) {
|
|
slidesPerViewParams = breakpointOnlyParams.slidesPerView;
|
|
}
|
|
}
|
|
|
|
let loopedSlides = Math.ceil(parseFloat(swiperParams.loopedSlides || slidesPerViewParams, 10));
|
|
loopedSlides += swiperParams.loopAdditionalSlides;
|
|
|
|
if (loopedSlides > slides.length && swiperParams.loopedSlidesLimit) {
|
|
loopedSlides = slides.length;
|
|
}
|
|
|
|
return loopedSlides;
|
|
}; |