From 2546bd927118d654cdd7ba52c9dd61bae4cb5eaf Mon Sep 17 00:00:00 2001 From: Alvaro Date: Mon, 14 Oct 2024 10:39:34 +0200 Subject: [PATCH] Fix carousel --- src/components/vertical-carousel/index.tsx | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/components/vertical-carousel/index.tsx b/src/components/vertical-carousel/index.tsx index a6e4e32..e865f45 100644 --- a/src/components/vertical-carousel/index.tsx +++ b/src/components/vertical-carousel/index.tsx @@ -1,7 +1,6 @@ - 'use client'; -import { motion, AnimatePresence, stagger } from 'framer-motion'; +import { motion, AnimatePresence } from 'framer-motion'; import { useEffect, useState, Children } from 'react'; const VerticalCarousel = ({ children, className }: @@ -30,27 +29,30 @@ const VerticalCarousel = ({ children, className }: useEffect(() => { const interval = setInterval(() => { - const nextIndex = (index + 1) % content.length; - setIndex(nextIndex); + setIndex((prevIndex) => (prevIndex + 1) % content.length); }, 3000); return () => clearInterval(interval); - }, [content.length, index]); + }, [content.length]); return (
- - - - {content[index]} - +
+ + {content.map((child, i) => ( + i === index && ( + + {child} + + ) + ))} - +
); } -export default VerticalCarousel; \ No newline at end of file +export default VerticalCarousel;