Skip to content

Commit

Permalink
refactor: rename loadMoreThreshold option to loadMoreCount
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Jun 1, 2021
1 parent 918085f commit 3c55e86
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-poems-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-cool-virtual": patch
---

refactor: rename `loadMoreThreshold` option to `loadMoreCount`
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface Options {
useIsScrolling?: UseIsScrolling;
scrollDuration?: number;
scrollEasingFunction?: ScrollEasingFunction;
loadMoreThreshold?: number;
loadMoreCount?: number;
isItemLoaded?: IsItemLoaded;
loadMore?: LoadMore;
onScroll?: OnScroll;
Expand Down
2 changes: 1 addition & 1 deletion src/types/react-cool-virtual.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ declare module "react-cool-virtual" {
useIsScrolling?: UseIsScrolling;
scrollDuration?: number;
scrollEasingFunction?: ScrollEasingFunction;
loadMoreThreshold?: number;
loadMoreCount?: number;
isItemLoaded?: IsItemLoaded;
loadMore?: LoadMore;
onScroll?: OnScroll;
Expand Down
12 changes: 6 additions & 6 deletions src/useVirtual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default <
useIsScrolling,
scrollDuration = 500,
scrollEasingFunction = easeInOutCubic,
loadMoreThreshold = 15,
loadMoreCount = 15,
isItemLoaded,
loadMore,
onScroll,
Expand Down Expand Up @@ -303,7 +303,7 @@ export default <
)
loadMoreRef.current({
startIndex: 0,
stopIndex: loadMoreThreshold - 1,
stopIndex: loadMoreCount - 1,
loadIndex: 0,
scrollOffset,
userScroll: userScrollRef.current,
Expand Down Expand Up @@ -388,8 +388,8 @@ export default <
userScroll: userScrollRef.current,
});

const loadIndex = Math.floor((vStop + 1) / loadMoreThreshold);
const startIndex = loadIndex * loadMoreThreshold;
const loadIndex = Math.floor((vStop + 1) / loadMoreCount);
const startIndex = loadIndex * loadMoreCount;

if (
loadMoreRef.current &&
Expand All @@ -398,7 +398,7 @@ export default <
)
loadMoreRef.current({
startIndex,
stopIndex: startIndex + loadMoreThreshold - 1,
stopIndex: startIndex + loadMoreCount - 1,
loadIndex,
scrollOffset,
userScroll: userScrollRef.current,
Expand All @@ -413,8 +413,8 @@ export default <
getCalcData,
getMeasure,
itemCount,
loadMoreCount,
loadMoreRef,
loadMoreThreshold,
marginKey,
onScrollRef,
resetIsScrolling,
Expand Down

0 comments on commit 3c55e86

Please sign in to comment.