From dd00932b65df0e7efdc10e4f4e72cf8da5ca8456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=9D=B1=E6=BE=94?= Date: Wed, 8 Sep 2021 13:40:35 +0800 Subject: [PATCH] fix: after data props update carousel not be can swipe --- src/Carousel.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Carousel.tsx b/src/Carousel.tsx index a0ac532e..20bc8cb4 100644 --- a/src/Carousel.tsx +++ b/src/Carousel.tsx @@ -135,7 +135,7 @@ function Carousel( const offsetX = useDerivedValue(() => { const x = handlerOffsetX.value % computedAnimResult.WL; return isNaN(x) ? 0 : x; - }, []); + }, [computedAnimResult]); const animatedListScrollHandler = useAnimatedGestureHandler( @@ -153,7 +153,7 @@ function Carousel( handlerOffsetX.value = Math.max( Math.min( ctx.startContentOffsetX + - Math.round(e.translationX), + Math.round(e.translationX), 0 ), -(data.length - 1) * width @@ -207,7 +207,7 @@ function Carousel( } }, }, - [loop] + [loop, data] ); React.useImperativeHandle(ref, () => {