[Help]: Changing autoplay delay disables slide animation #984
-
SummaryFirst i wanna thank for this wonderful package! So I'm using shadcn carousel for this, but i think it has the same implementation. This happens not only on autoplay but even just going next and prev slides. I wonder if im doing it on the wrong place, here's my code: const { current, setApi } = useCarouselApi({opacity: true});
const [delay, setDelay] = useState(3500);
useEffect(() => {
setDelay(data[current].duration)
}, [current]);
return (
<div className="relative">
<Carousel
setApi={setApi}
opts={{loop: true, align: 'center'}}
plugins={[
Autoplay({
delay: delay,
jump: false,
stopOnInteraction: false,
}),
]}
>
<CarouselContent>
{data?.map((item, index) => (
<CarouselItem key={index} className="xl:basis-[70%]">
<AspectRatio ratio={6 / 2}>
<div className="w-full h-full flex items-center">
<Image
className="rounded-md"
src={item.imageWeb || ''}
alt={''}
width={5000} height={1000}
/>
</div>
</AspectRation>
</CarouselItem>
)}
</CarouselContent>
<div className="absolute bottom-0 right-0 m-5 md:flex gap-1 hidden">
<CarouselAutoPlay/>
<CarouselPrevious/>
<CarouselNext/>
</div>
</Carousel>
</div>
) If applicable, which variants of Embla Carousel are relevant to this question?
Additional informationNo response CodeSandbox exampleNo response |
Beta Was this translation helpful? Give feedback.
Answered by
davidjerleke
Aug 27, 2024
Replies: 1 comment 5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ezanglo as I already said in my previous comment: The feature is on the roadmap, meaning it hasn’t been implemented yet. Which also means it’s not supported at the time of writing.
Changing delay like that now will reset the carousel because it will detect changes on the plugin.