$(document).ready(function(){
let inProgress = false;
let count = 20;
let begin = 1;
let currentPage = $('.main').data("page");
var getUserId = $('.subs_list_wrp').data("id");
if(currentPage == 'feed') {
var pageUrl = '../ajax_controller/load_feed_content.php';
}
if(currentPage == 'user') {
var pageUrl = '../ajax_controller/load_user_content?id=' + getUserId;
}
function scrolling(){
if ($(document).height() - $(window).height() <= $(window).scrollTop() && !inProgress) {
$(this).unbind("scroll");
loader();
}
}
function loader(){
$.ajax({
type:"POST",
url: pageUrl,
data:{
count: count,
begin: begin*count
},beforeSend: function() {
inProgress = true;},
success:onAjaxSuccess
});
function onAjaxSuccess(data) {
if(!$.trim(data)) {
inProgress = false;
} else{
$(".content_list").append(data);
begin++;
$(window).on("scroll", scrolling);
}
}
inProgress = false;
}
$(document).on("scroll", scrolling);
$(document).on("scrollstart",scrolling);
});