How to use the class after increasing the height of the screen?

When I scroll the page down, block .profile_cover_sidebar_style add a class .coverfixed

fixed

$(document).scroll(function(){
 if ($(document).scrollTop() >= 1000) {
$('.profile_cover_sidebar_style').addClass('coverfixed');
 } else {
$('.profile_cover_sidebar_style').removeClass('coverfixed');
}
 });



Up to this point everything works fine. But if you scroll down the page to the bottom of the Ajax starts loading the next batch of content and then not working fixed

ajax

$(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
});

 onAjaxSuccess function(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);
 });



screen
5e2963bc9042a001894066.png


p.here's filled frii host. can check the Same website
p.s.s if anyone knows how best to implement the download of the content "chunks" that I will be glad to your advice
April 4th 20 at 13:27
1 answer
April 4th 20 at 13:29
Solution
In functions of scrolling you remove all handlers for the scroll event of the document element. It is therefore not triggered event handling declared in the top.

Find more questions by tags JavaScriptjQuery