javascript - Infinite scrolling implementation -


am trying lazy loading during onscroll. below code:

$(window).scroll(                function() {                   if ($(window).scrolltop() > ($(document).height() - $(window).height() - 200) && !loadnews))                  {                         loadnews = true;                         loadmorenewsitems();                  }             });  

loadmorenewsitems() ajax call , appends data, on success of ajax call setting loadnews flag false again.

is above implementation correct. have subtracted 200 because of footer block available below newsitems.

when check, user has scroll till footer loading more newsitems. checking on mobile device. probelm here.

and, when scroll fast there multiple ajax requests. but, have added loadnews flag avoiding that. but, not work either.

please help.

this use infinite scrolling

var d=document; var remainingheight=d.scrollheight - d.clientheight - (d.scrolltop || document.body.scrolltop);  if(remainingheight < 500){      //do loading process } 

you should give try instead of current test, should fix problem mobiles.

also, multiple ajax request , flag, problem && !loadnews not placed correctly in test, in wrong set of parenthesis.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -