Optimistically update the pager tab bar on swipe (#2083)

zio/stable
Paul Frazee 2023-12-04 16:06:15 -08:00 committed by GitHub
parent 8e2cfa52de
commit 6e2eaa746d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -81,12 +81,14 @@ export const Pager = forwardRef<PagerRef, React.PropsWithChildren<Props>>(
if (scrollState.current === 'settling') { if (scrollState.current === 'settling') {
if (lastDirection.current === -1 && offset < lastOffset.current) { if (lastDirection.current === -1 && offset < lastOffset.current) {
onPageSelecting?.(position) onPageSelecting?.(position)
setSelectedPage(position)
lastDirection.current = 0 lastDirection.current = 0
} else if ( } else if (
lastDirection.current === 1 && lastDirection.current === 1 &&
offset > lastOffset.current offset > lastOffset.current
) { ) {
onPageSelecting?.(position + 1) onPageSelecting?.(position + 1)
setSelectedPage(position + 1)
lastDirection.current = 0 lastDirection.current = 0
} }
} else { } else {