From 27b2e704b4849de48441330b0b88f5471b279b4b Mon Sep 17 00:00:00 2001 From: Daniel Merrill Date: Tue, 21 Nov 2023 15:40:05 -0800 Subject: [PATCH] fix bug in setPage allowing for paging outside of min/max range --- src/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 39ca235..7b04f85 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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, @@ -190,7 +193,7 @@ function InfinitePager( translate.value = updatedTranslate; } }, - [pageSize, translate] + [pageSize, translate, minIndex, maxIndex] ); useImperativeHandle(