Simular el efecto FadeIn de jQuery usando solo Vanilla JS. La siguiente función fadeIn() consta de 2 parámetros: elemento y duración (este ultimo opcional).
function fadeIn(element, duration = 600) { element.style.display = ''; element.style.opacity = 0; var last = +new Date(); var tick = function() { element.style.opacity = +element.style.opacity + (new Date() - last) / duration; last = +new Date(); if (+element.style.opacity < 1) { (window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16); } }; tick(); }
Demo:
Y para el efecto contrario puedes ver: https://bufa.es/vanilla-js-fadeout/
Agradezco tu comentario 🤘