Heyo,
so I was wondering if it is possible to show the fade-effect of a div, if it is 20% away from the bottom within the currend screen view. So for example if you scroll down on a page and the following contentbox gets a distance of 20% of the screen-height to the bottom of the screen, the fade-in effect runs.
I want this because of the responsive function. I don't want to write a new pixel height for the fade-effect everytime the Screensize changes.
Here's the code I'm currently using:
function Scroll(){
var top = document.getElementById('div1');
var ypos = window.pageYOffset;
if (ypos > 1000){
top.style.opacity = "1";
}
else {
top.style.opacity = "0";
}
}
window.addEventListener("scroll",Scroll);