Skip to content

Commit

Permalink
fix bug in setPage allowing for paging outside of min/max range
Browse files Browse the repository at this point in the history
  • Loading branch information
computerjazz committed Nov 21, 2023
1 parent b4ffcf7 commit 27b2e70
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ function InfinitePager(
const setPage = useCallback(
(index: number, options: ImperativeApiOptions = {}) => {
const updatedTranslate = index * pageSize.value * -1;

if (index < minIndex || index > maxIndex) return;

if (options.animated) {
const animCfg = {
...DEFAULT_ANIMATION_CONFIG,
Expand All @@ -190,7 +193,7 @@ function InfinitePager(
translate.value = updatedTranslate;
}
},
[pageSize, translate]
[pageSize, translate, minIndex, maxIndex]
);

useImperativeHandle(
Expand Down

0 comments on commit 27b2e70

Please sign in to comment.