#69 : Code cleanup
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user