Optimistically update the pager tab bar on swipe (#2083)
parent
8e2cfa52de
commit
6e2eaa746d
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue