Rename perPage => slidesToShow
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
import {
|
import {
|
||||||
getPageIndex,
|
getPageIndex,
|
||||||
getPagesCount,
|
getPagesCount,
|
||||||
getPerPageTail,
|
getSlidesToShowTail,
|
||||||
getSlideSize,
|
getSlideSize,
|
||||||
getIsNotCompletePage
|
getIsNotCompletePage
|
||||||
} from './utils/size'
|
} from './utils/size'
|
||||||
@@ -22,9 +22,9 @@
|
|||||||
export let infinite = true
|
export let infinite = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elements per page
|
* Number of slides to show at a time
|
||||||
*/
|
*/
|
||||||
export let perPage = 1
|
export let slidesToShow = 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page to start on
|
* Page to start on
|
||||||
@@ -47,13 +47,13 @@
|
|||||||
contentContainerWidth = contentContainerElement.clientWidth
|
contentContainerWidth = contentContainerElement.clientWidth
|
||||||
|
|
||||||
const slidesCount = children.length
|
const slidesCount = children.length
|
||||||
pagesCount = getPagesCount({ slidesCount, perPage })
|
pagesCount = getPagesCount({ slidesCount, slidesToShow })
|
||||||
const perPageTail = getPerPageTail({ pagesCount, perPage, slidesCount })
|
const slidesToShowTail = getSlidesToShowTail({ pagesCount, slidesToShow, slidesCount })
|
||||||
|
|
||||||
for (let slideIndex=0; slideIndex<children.length; slideIndex++) {
|
for (let slideIndex=0; slideIndex<children.length; slideIndex++) {
|
||||||
const pageIndex = getPageIndex({ slideIndex, perPage })
|
const pageIndex = getPageIndex({ slideIndex, slidesToShow })
|
||||||
const isNotCompletePage = getIsNotCompletePage({ pageIndex, pagesCount })
|
const isNotCompletePage = getIsNotCompletePage({ pageIndex, pagesCount })
|
||||||
const slideSizePx = getSlideSize({ isNotCompletePage, contentContainerWidth, perPage, perPageTail })
|
const slideSizePx = getSlideSize({ isNotCompletePage, contentContainerWidth, slidesToShow, slidesToShowTail })
|
||||||
children[slideIndex].style.minWidth = `${slideSizePx}px`
|
children[slideIndex].style.minWidth = `${slideSizePx}px`
|
||||||
children[slideIndex].style.maxWidth = `${slideSizePx}px`
|
children[slideIndex].style.maxWidth = `${slideSizePx}px`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
export let infinite = true;
|
export let infinite = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elements per page
|
* Number of slides to show at a time
|
||||||
*/
|
*/
|
||||||
export let perPage = 1;
|
export let slidesToShow = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page to start on
|
* Page to start on
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
<ImageCarousel
|
<ImageCarousel
|
||||||
{arrows}
|
{arrows}
|
||||||
{infinite}
|
{infinite}
|
||||||
{perPage}
|
{slidesToShow}
|
||||||
{initialPage}
|
{initialPage}
|
||||||
{speed}
|
{speed}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
export function getPagesCount({ slidesCount, perPage }) {
|
export function getPagesCount({ slidesCount, slidesToShow }) {
|
||||||
return Math.ceil(slidesCount/perPage)
|
return Math.ceil(slidesCount/slidesToShow)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPerPageTail({
|
export function getSlidesToShowTail({
|
||||||
perPage,
|
slidesToShow,
|
||||||
slidesCount,
|
slidesCount,
|
||||||
pagesCount
|
pagesCount
|
||||||
}) {
|
}) {
|
||||||
return slidesCount - perPage * (pagesCount - 1)
|
return slidesCount - slidesToShow * (pagesCount - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getIsNotCompletePage({
|
export function getIsNotCompletePage({
|
||||||
@@ -19,15 +19,15 @@ export function getIsNotCompletePage({
|
|||||||
|
|
||||||
export function getSlideSize({
|
export function getSlideSize({
|
||||||
contentContainerWidth,
|
contentContainerWidth,
|
||||||
perPage,
|
slidesToShow,
|
||||||
perPageTail,
|
slidesToShowTail,
|
||||||
isNotCompletePage
|
isNotCompletePage
|
||||||
}) {
|
}) {
|
||||||
return isNotCompletePage
|
return isNotCompletePage
|
||||||
? Math.round(contentContainerWidth/perPageTail)
|
? Math.round(contentContainerWidth/slidesToShowTail)
|
||||||
: Math.round(contentContainerWidth/perPage)
|
: Math.round(contentContainerWidth/slidesToShow)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPageIndex({ slideIndex, perPage }) {
|
export function getPageIndex({ slideIndex, slidesToShow }) {
|
||||||
return Math.floor(slideIndex/perPage)
|
return Math.floor(slideIndex/slidesToShow)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user