Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scroll event not working on mobile

Setch.me loading normally on desktop but not trigerring on mobile unless if I click on photographers/makeup artists, I've added height=device-height after searching for a solution here but that didn't work.

$(window).scroll(function() { 
    if($(window).scrollTop() + $(window).height() >= $(document).height()) { 
        track_page++; 
        load_contents(track_page); 
    }
like image 930
Kareem Kamal Avatar asked Jun 25 '17 08:06

Kareem Kamal


1 Answers

Try this:

$(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); 
    }
}
like image 171
vsync Avatar answered Oct 20 '22 21:10

vsync