#69 : Code cleanup
This commit is contained in:
@@ -2,15 +2,6 @@ import {
|
||||
getValueInRange,
|
||||
} from './math'
|
||||
|
||||
export function applyParticleSizes({
|
||||
particlesContainerChildren,
|
||||
particleWidth,
|
||||
}) {
|
||||
for (let particleIndex=0; particleIndex<particlesContainerChildren.length; particleIndex++) {
|
||||
particlesContainerChildren[particleIndex].style.minWidth = `${particleWidth}px`
|
||||
particlesContainerChildren[particleIndex].style.maxWidth = `${particleWidth}px`
|
||||
}
|
||||
}
|
||||
|
||||
// getCurrentPageIndexByCurrentParticleIndex
|
||||
|
||||
@@ -58,24 +49,6 @@ export function getCurrentPageIndexByCurrentParticleIndex({
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: think about case if particlesCount < particlesToShow and particlesCount < particlesToScroll
|
||||
export function getPartialPageSize({
|
||||
particlesToScroll,
|
||||
particlesToShow,
|
||||
particlesCountWithoutClones,
|
||||
}) {
|
||||
const overlap = particlesToScroll - particlesToShow
|
||||
let particlesCount = particlesToShow
|
||||
|
||||
while(true) {
|
||||
const diff = particlesCountWithoutClones - particlesCount - overlap
|
||||
if (diff < particlesToShow) {
|
||||
return diff
|
||||
}
|
||||
particlesCount += particlesToShow + overlap
|
||||
}
|
||||
}
|
||||
|
||||
// getPagesCountByParticlesCount
|
||||
|
||||
export function _getPagesCountByParticlesCountInfinite({
|
||||
@@ -162,6 +135,34 @@ export function getParticleIndexByPageIndex({
|
||||
})
|
||||
}
|
||||
|
||||
export function applyParticleSizes({
|
||||
particlesContainerChildren,
|
||||
particleWidth,
|
||||
}) {
|
||||
for (let particleIndex=0; particleIndex<particlesContainerChildren.length; particleIndex++) {
|
||||
particlesContainerChildren[particleIndex].style.minWidth = `${particleWidth}px`
|
||||
particlesContainerChildren[particleIndex].style.maxWidth = `${particleWidth}px`
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: think about case if particlesCount < particlesToShow and particlesCount < particlesToScroll
|
||||
export function getPartialPageSize({
|
||||
particlesToScroll,
|
||||
particlesToShow,
|
||||
particlesCountWithoutClones,
|
||||
}) {
|
||||
const overlap = particlesToScroll - particlesToShow
|
||||
let particlesCount = particlesToShow
|
||||
|
||||
while(true) {
|
||||
const diff = particlesCountWithoutClones - particlesCount - overlap
|
||||
if (diff < particlesToShow) {
|
||||
return diff
|
||||
}
|
||||
particlesCount += particlesToShow + overlap
|
||||
}
|
||||
}
|
||||
|
||||
export function createResizeObserver(onResize) {
|
||||
return new ResizeObserver(entries => {
|
||||
onResize({
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import {
|
||||
getPartialPageSize,
|
||||
_getCurrentPageIndexByCurrentParticleIndexInfinite
|
||||
// getCurrentPageIndex,
|
||||
// getPagesCountByParticlesCount,
|
||||
// getParticleIndexByPageIndexInfinite,
|
||||
// getParticleIndexByPageIndexLimited,
|
||||
getPartialPageSize,
|
||||
_getCurrentPageIndexByCurrentParticleIndexInfinite,
|
||||
_getCurrentPageIndexByCurrentParticleIndexLimited,
|
||||
_getPagesCountByParticlesCountInfinite,
|
||||
_getPagesCountByParticlesCountLimited,
|
||||
_getParticleIndexByPageIndexInfinite,
|
||||
_getParticleIndexByPageIndexLimited,
|
||||
} from './page.js'
|
||||
|
||||
describe('getPartialPageSize', () => {
|
||||
|
||||
Reference in New Issue
Block a user