#69 : Determine partial window content size

This commit is contained in:
Vadim
2021-09-05 15:34:27 +03:00
parent ff17d083e8
commit 0b51d17ad7
4 changed files with 234 additions and 29 deletions

View File

@@ -111,3 +111,40 @@ export function applyPageSizes({
pagesContainerChildren[pageIndex].style.maxWidth = `${pageWidth}px`
}
}
export function getCurrentPageIndexWithoutClones({
currentPageIndex,
pagesCount,
oneSideClonesCount,
infinite,
pagesToScroll,
}) {
if (infinite) {
if (currentPageIndex === pagesCount - oneSideClonesCount) return 0
if (currentPageIndex === 0) return pagesCount - oneSideClonesCount
return Math.floor((currentPageIndex - oneSideClonesCount) / pagesToScroll)
}
return currentPageIndex
}
export function getPagesCountWithoutClones({
pagesCount,
infinite,
oneSideClonesCount,
pagesToScroll,
}) {
const bothSidesClonesCount = oneSideClonesCount * 2
return Math.max(
Math.ceil(
(pagesCount - (infinite ? bothSidesClonesCount : 0)) / pagesToScroll
),
1)
}
// TODO: check
export function getOneSideClonesCount({
pagesToScroll,
pagesToShow,
}) {
return Math.max(pagesToScroll, pagesToShow) // max - show 4, scroll 3, pages 7
}