window.addEventListener('scroll',function(){
if(window.pageYOffset > 100)
{
document.getElementById('fade').style.opacity=1;
}
else
{
document.getElementById('fade').style.opacity=0;
}
});
JavaScript fad-in fade-out animation with scrolling event or without using libraries API, only with logics
To achieve this you can use the CSS
transitionandopacityproperties with a class that you toggle via JS to fade in/out an element: