docs: fix carousel not working properly (#2222)

Currently, the [Carousel component](https://fresh.deno.dev/components)
only shows "slide four" without moving to other slides.
This PR will fix that issue.
This commit is contained in:
David Luis
2024-01-10 10:31:06 +01:00
committed by GitHub
parent f63752062a
commit 8d01051b5b
+1 -2
View File
@@ -75,14 +75,13 @@ const Carousel = (props: CarouselProps) => {
let incomingSlide = currentSlide.value + 1;
if (outgoingSlide === -1) outgoingSlide = SLIDE_DATA.length - 1;
if (incomingSlide === SLIDE_DATA.length) incomingSlide = 0;
// console.log(outgoingSlide, currentSlide.value, incomingSlide)
const TRANSITION_CLASS = () => {
if (currentSlide.value === idx) return "translate-x-0 z-20";
if (incomingSlide === idx) return "translate-x-full z-10";
if (outgoingSlide === idx) return "-translate-x-full z-10";
return "translate-x-full";
};
return `slide absolute top-0 left-0 transition-all ease-in-out duration-700 transform ${TRANSITION_CLASS}`;
return `slide absolute top-0 left-0 transition-all ease-in-out duration-700 transform ${TRANSITION_CLASS()}`;
};
const nextSlide = () => {