Skip to content

Commit a3a537d

Browse files
petrkonecny2Petr Konecny
andauthored
fix: fixed crash when manually scrolling (#23)
Co-authored-by: Petr Konecny <[email protected]>
1 parent 6e50935 commit a3a537d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/hooks/useManualScroll.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ export const useManualScroll = ({
1414
const scrollValue = useSharedValue(initialIndex)
1515

1616
const goToPage = useCallback(
17-
(page: number, duration = 0, animation = DEFAULT_ANIMATION) => {
17+
(page: number, duration = 0, animation?: typeof DEFAULT_ANIMATION) => {
1818
'worklet'
1919
const to = page * slideWidth
2020
if (duration) {
21-
manualScrollValue.value = { value: animation(to, duration) }
21+
manualScrollValue.value = {
22+
value: animation ? animation(to, duration) : withTiming(to, { duration }),
23+
}
2224
} else {
2325
manualScrollValue.value = { value: to }
2426
}

0 commit comments

Comments
 (0)