diff --git a/src/utils/page.js b/src/utils/page.js index f66051f..d0e0a98 100644 --- a/src/utils/page.js +++ b/src/utils/page.js @@ -157,7 +157,7 @@ export function getPartialPageSize({ while(true) { const diff = particlesCountWithoutClones - particlesCount - overlap if (diff < particlesToShow) { - return diff + return Math.max(diff, 0) // show: 2; scroll: 3, n: 5 => -1 } particlesCount += particlesToShow + overlap } diff --git a/src/utils/page.test.js b/src/utils/page.test.js index 6fad144..4c451ea 100644 --- a/src/utils/page.test.js +++ b/src/utils/page.test.js @@ -40,6 +40,11 @@ describe('getPartialPageSize', () => { particlesToShow: 2, particlesToScroll: 2, expected: 0, + }, { + particlesCountWithoutClones: 5, + particlesToShow: 2, + particlesToScroll: 3, + expected: 0, }] testCases.forEach(({