In my React app, I have a slider that moves my card components when any of the icon buttons are clicked. I'm trying to implement a fade animation for each card when it is clicked, but currently, the animation only works when the page is reloaded. Here is the snippet of code I am using:
<div className={classes.root}>
<div className={classes.slider}>
<Card image={carddata[slider].image} slider />
</div>
<ArrowBackIosIcon
fontSize="large"
style={{ left: 0 }}
className={classes.arrow}
onClick={prevSlide}
/>
<ArrowForwardIosIcon
fontSize="large"
style={{ right: 0 }}
className={classes.arrow}
onClick={nextSlide}
/>
</div>
Here is the CSS class used for the animation:
slider: {
animation: 'fadeeffect 3000ms linear 250ms',
},
@keyframes fadeeffect: {
"0%": {
opacity: 0,
},
"25%": {
opacity: 0.25,
},
"50%": {
opacity: 0.5,
},
"100%": {
opacity: 1,
},
},