var amount = document.getElementsByClassName("cart-total-qty")[0].innerHTML;
console.log(amount);
var body = document.body,
html = document.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
var tenPercent = height*.9
window.addEventListener("scroll", function() {
scrollAmount = window.scrollY;
if(scrollAmount == tenPercent){
alert("It's happening (Insert Ron Paul)");
}
});
In my code above i am getting the height of the page using an example i found here: How to get height of entire document with JavaScript?
I am then trying to trigger an event once the user has scrolled to the bottom ten percent of the page. The problem is that scrollAmount
does not ever reach within 10% of height
In my example height
is returned as 1280 and scrollAmount
never returns higher then 1040 while scrolling, but the strange part is that if i change the height of my browser i get different results for scrollAmount
when i scroll to the bottom.