#69 : Code cleanup

This commit is contained in:
Vadim
2021-09-13 22:46:32 +03:00
parent 6108dbf910
commit 3715f77af1
3 changed files with 8 additions and 8 deletions

View File

@@ -10,7 +10,7 @@
import { tappable } from '../../actions/tappable' import { tappable } from '../../actions/tappable'
import { import {
addResizeEventListener, addResizeEventListener,
removeResizeEventListener removeResizeEventListener,
} from '../../utils/event' } from '../../utils/event'
import { import {
applyParticleSizes, applyParticleSizes,

View File

@@ -1,6 +1,6 @@
import { getValueInRange } from './math' import { getValueInRange } from './math'
export function getIndexesOfPagesWithoutClonesInScroll({ export function getIndexesOfParticlesWithoutClonesInPage({
pageIndex, pageIndex,
particlesToShow, particlesToShow,
particlesToScroll, particlesToScroll,
@@ -47,7 +47,7 @@ export function getAdjacentIndexes({
pagesCount - 1, // needed to clone last page particles pagesCount - 1, // needed to clone last page particles
])].sort((a, b) => a - b) ])].sort((a, b) => a - b)
const particleIndexes = pageIndexes.flatMap( const particleIndexes = pageIndexes.flatMap(
pageIndex => getIndexesOfPagesWithoutClonesInScroll({ pageIndex => getIndexesOfParticlesWithoutClonesInPage({
pageIndex, pageIndex,
particlesToShow, particlesToShow,
particlesToScroll, particlesToScroll,

View File

@@ -1,9 +1,9 @@
import { import {
getIndexesOfPagesWithoutClonesInScroll, getIndexesOfParticlesWithoutClonesInPage,
getAdjacentIndexes, getAdjacentIndexes,
} from './lazy.js' } from './lazy.js'
describe('getIndexesOfPagesWithoutClonesInScroll', () => { describe('getIndexesOfParticlesWithoutClonesInPage', () => {
it('returns correct range if particlesToShow < particlesToScroll', () => { it('returns correct range if particlesToShow < particlesToScroll', () => {
const testCases = [ const testCases = [
{ pageIndex: 0, particlesToShow: 3, particlesCount: 9, particlesToScroll: 4, expected: [0, 1, 2, 3] }, { pageIndex: 0, particlesToShow: 3, particlesCount: 9, particlesToScroll: 4, expected: [0, 1, 2, 3] },
@@ -17,7 +17,7 @@ describe('getIndexesOfPagesWithoutClonesInScroll', () => {
particlesCount, particlesCount,
expected, expected,
}) => { }) => {
expect(getIndexesOfPagesWithoutClonesInScroll({ expect(getIndexesOfParticlesWithoutClonesInPage({
pageIndex, pageIndex,
particlesToShow, particlesToShow,
particlesToScroll, particlesToScroll,
@@ -39,7 +39,7 @@ describe('getIndexesOfPagesWithoutClonesInScroll', () => {
particlesCount, particlesCount,
expected, expected,
}) => { }) => {
expect(getIndexesOfPagesWithoutClonesInScroll({ expect(getIndexesOfParticlesWithoutClonesInPage({
pageIndex, pageIndex,
particlesToShow, particlesToShow,
particlesToScroll, particlesToScroll,
@@ -61,7 +61,7 @@ describe('getIndexesOfPagesWithoutClonesInScroll', () => {
particlesCount, particlesCount,
expected, expected,
}) => { }) => {
expect(getIndexesOfPagesWithoutClonesInScroll({ expect(getIndexesOfParticlesWithoutClonesInPage({
pageIndex, pageIndex,
particlesToShow, particlesToShow,
particlesToScroll, particlesToScroll,