$(window).scrolltop() not working on mobile 1

$(window).scrolltop() not working on mobile

$(document.body).on('touchmove', onScroll); // for mobile
$(window).on('scroll', onScroll); 

// callback
function onScroll(){ 
    if( $(window).scrollTop() + window.innerHeight >= document.body.scrollHeight ) { 
        track_page++; 
        load_contents(track_page); 
    }
}

Here is what the above code is Doing:
1. We are using jQuery to bind the scroll event to the window object.
2. We are checking if the user has scrolled to the bottom of the page.
3. If the user has scrolled to the bottom of the page, we are incrementing the track_page variable by 1.
4. We are calling the load_contents() function to load the next set of contents.

Now, let’s see how the load_contents() function looks like:

Similar Posts