I am using this jQuery script but it works backwards
var heightPage = $(document).height();
$(window).scroll(function(){
if(($(window).scrollTop() + $(window).height()) == heightPage) {
alert("final de la página");
}
});
it's supposed to run alert
when you get to the bottom of the page but it runs when you get to the top
I have achieved the goal thanks to a publication in English on github, the script is as follows:
It is a bit more complex (more lines of code and more operations) but in my strange case it worked as I needed, it is an alternative for the same function
Gist link on Github: https://gist.github.com/toshimaru/6102647
Find the end of a div's scroll
Lately I had the need for something similar but instead of the whole page I needed to find the end of the scroll of a single div.
The code is pure JavaScript
I think I was able to get it with vanilla javascript, I hope someone else finds it useful: