I have some jQuery code to check if I've scrolled to the bottom of the window.
$(window).scroll(function(){
if($(window).scrollTop() + $(window).height() == $(document).height()) {
appendToGrid();
}
})
My appendToGrid() function scrolls the user to the top of the page and adds content. Problem is, I need this function called once per scroll. As I have it now, it is called multiple times per scroll.
If I change it to
$(window).one('scroll',function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
appendToGrid();
}
});
it will only fire once total, but I need it to fire once per scroll so the user can scroll to the bottom and keep getting sent back to the top of the page.
I've also tried the below but it still fires multiple times.
var fired = false;
$(window).scroll(function(){
if($(window).scrollTop() + $(window).height() == $(document).height() && !fired) {
fired = true;
appendToGrid();
fired = false;
}
})