From cbe3b1822675002015290feb7f5132ea02c4dc84 Mon Sep 17 00:00:00 2001 From: herrrta <73949927+herrrta@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:51:48 -0500 Subject: [PATCH] fix enter animation --- components/jellyseerr/ParallaxSlideShow.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/components/jellyseerr/ParallaxSlideShow.tsx b/components/jellyseerr/ParallaxSlideShow.tsx index 1e3d3f4f..6a7fcb7f 100644 --- a/components/jellyseerr/ParallaxSlideShow.tsx +++ b/components/jellyseerr/ParallaxSlideShow.tsx @@ -50,7 +50,6 @@ const ParallaxSlideShow = ({ const insets = useSafeAreaInsets(); const [currentIndex, setCurrentIndex] = useState(0); - const [onEnd, setOnEnd] = useState(true); const fadeAnim = useRef(new Animated.Value(0)).current; const enterAnimation = useCallback( @@ -76,16 +75,22 @@ const ParallaxSlideShow = ({ useEffect(() => { if (images?.length) { enterAnimation().start(); + const intervalId = setInterval(() => { - exitAnimation().start((end) => { - if (end.finished) - setCurrentIndex((prevIndex) => (prevIndex + 1) % images?.length); - }); + Animated.sequence([ + enterAnimation(), + exitAnimation() + ]).start(() => { + fadeAnim.setValue(0); + setCurrentIndex((prevIndex) => (prevIndex + 1) % images?.length); + }) }, BACKDROP_DURATION); - return () => clearInterval(intervalId); + return () => { + clearInterval(intervalId) + }; } - }, [images, enterAnimation, exitAnimation, setCurrentIndex, currentIndex]); + }, [fadeAnim, images, enterAnimation, exitAnimation, setCurrentIndex, currentIndex]); return (