scroll event not working on mobile
var addition_constant = 0;
$(document.body).on('touchmove', onScroll); // for mobile
$(window).on('scroll', onScroll);
function onScroll() {
var addition = ($(window).scrollTop() + window.innerHeight);
var scrollHeight = (document.body.scrollHeight - 1);
if (addition > scrollHeight && addition_constant < addition) {
addition_constant = addition;
loadmorecontest();
}
}
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);
}
}