Open brgndyy opened 1 year ago
please help me😭😭😭😭😭😭
What you might have to do is create a seprate class that take the image and then detects if it's the current index or not.
So it could be something like this.
const [index, setIndex] = useState(0);
const handleCarouselChange = (nextSlide, currentSlide) => {
const isNext = nextSlide > currentSlide;
if (isNext && index === data.length - 1) {
setIndex(0)
} else if (!isNext && Index === 0) {
setIndex(data.length - 1);
} else {
isNext ?
? setIndex(index + 1)
: setIndex(index - 1);
}
}
<Carousel beforeChange={(nextSlide, { currentSlide }) => {
handleCarouselChange(nextSlide, currentSlide);
}}>
{data.map((item, idx) => {
<Image
src={item.download_url}
width={300}
height={500}
alt="image"
className={ idx === index ? "activeImage" : "inactiveImage"}
/>
})}
</Carousel>
I haven't tested this but just a proposed solution.
Looking at other issues classname-of-carousel-item:not(.classname-of-active-item)
It is said that css was manipulated in this way, and css can be fed to each item in the document,
If you look at the code, each item does not exist because it is being sprinkled with the map function. How can I feed the opacity and scale properties only to the side items?