let elementToFade = document.getElementById("detail-poster")
let fadeEffect = setInterval(function () {
if (!elementToFade.style.opacity) {
elementToFade.style.opacity = 1
}
if (elementToFade.style.opacity > 0) {
elementToFade.style.opacity -= 0.1
} else {
clearInterval(fadeEffect)
}
this.num = (this.num + 1) % this.backDropImage?.backdrops.length
}, 200)
}
I have successfully implemented a vanilla JavaScript fade out effect, but I am struggling to create a fade in effect. Does anyone know how to achieve this using plain JavaScript?