Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed Oct 13, 2024
1 parent ce55ae5 commit 15eb9c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/core/cache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ describe(computeRange.name, () => {
30
),
0,
INITIAL_INDEX,
100
100,
INITIAL_INDEX
)
).toEqual([0, 5]);
});
Expand All @@ -353,8 +353,8 @@ describe(computeRange.name, () => {
30
),
20,
INITIAL_INDEX,
100
100,
INITIAL_INDEX
)
).toEqual([1, 6]);
});
Expand All @@ -365,7 +365,7 @@ describe(computeRange.name, () => {
30
);
const last = cache._length - 1;
expect(computeRange(cache, sum(cache._sizes), INITIAL_INDEX, 100)).toEqual([
expect(computeRange(cache, sum(cache._sizes), 100, INITIAL_INDEX)).toEqual([
last,
last,
]);
Expand All @@ -378,7 +378,7 @@ describe(computeRange.name, () => {
);
const last = cache._length - 1;
expect(
computeRange(cache, sum(cache._sizes) - 20, INITIAL_INDEX, 100)
computeRange(cache, sum(cache._sizes) - 20, 100, INITIAL_INDEX)
).toEqual([last, last]);
});

Expand All @@ -389,7 +389,7 @@ describe(computeRange.name, () => {
);
const last = cache._length - 1;
expect(
computeRange(cache, sum(cache._sizes) - 20 - 1, INITIAL_INDEX, 100)
computeRange(cache, sum(cache._sizes) - 20 - 1, 100, INITIAL_INDEX)
).toEqual([last - 1, last]);
});

Expand All @@ -401,8 +401,8 @@ describe(computeRange.name, () => {
30
),
-1000,
INITIAL_INDEX,
100
100,
INITIAL_INDEX
)
).toEqual([0, 0]);
});
Expand All @@ -414,7 +414,7 @@ describe(computeRange.name, () => {
);
const last = cache._length - 1;
expect(
computeRange(cache, sum(cache._sizes) + 1000, INITIAL_INDEX, 100)
computeRange(cache, sum(cache._sizes) + 1000, 100, INITIAL_INDEX)
).toEqual([last, last]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/core/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export const findIndex = (cache: Cache, offset: number, i: number): number => {
export const computeRange = (
cache: Cache,
scrollOffset: number,
prevStartIndex: number,
viewportSize: number
viewportSize: number,
prevStartIndex: number
): ItemsRange => {
const start = findIndex(
cache,
Expand Down
2 changes: 1 addition & 1 deletion src/core/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const createVirtualStore = (
const subscribers = new Set<[number, Subscriber]>();
const getRelativeScrollOffset = () => scrollOffset - startSpacerSize;
const getRange = (offset: number) => {
return computeRange(cache, offset, _prevRange[0], viewportSize);
return computeRange(cache, offset, viewportSize, _prevRange[0]);
};
const getTotalSize = (): number => computeTotalSize(cache);
const getItemOffset = (index: number): number => {
Expand Down

0 comments on commit 15eb9c4

Please sign in to comment.