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


 if ($(document).scrollTop() >= 1000) {
 } else {

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


 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) { 

 function loader(){

 url: pageUrl,
 count: count,
 begin: begin*count
 },beforeSend: function() {
 inProgress = true;}, 

 onAjaxSuccess function(data) { 
 if(!$.trim(data)) {
 inProgress = false;
 } else{
 $(window).on("scroll", scrolling);
 inProgress = false;

 $(document).on("scroll", scrolling);

5e2963bc9042a001894066.png'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
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