UNPKG

swiper

Version:

Most modern mobile touch slider and framework with hardware accelerated transitions

22 lines (17 loc) 819 B
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; };