jquery - "Infinite scroll"-like. Make it fire before bottom -


i'm using small script define if user've scrolled bottom

$(window).scroll(function(){      if($(window).scrolltop() == $(document).height() - $(window).height()){         if(!taskfired){             taskfired = true;             $("#loading_gif").css("display", "block");             settimeout(loadmoremabs, 1500);         }     }  }); 

but wan't fire function loadmoremabs before bottom reached. how that? i've tried + , - heights, it's i'm experimenting don't get.

what question title suggests want

subtract value $(document).height() 50 start loading 50 pixels bottom.

if($(window).scrolltop() <= ($(document).height() - 50) - $(window).height()){ 

here little demo in jsfiddle, made dummy function fulfill loadmoremabs function

http://jsfiddle.net/sg3s/uwxaw/

fires every time near bottom , 1500ms expire.

now make fire (immediatly) if reaches bottom.

(since suggests else)

http://jsfiddle.net/sg3s/uwxaw/1/

the trick >= in equation, making sure fires if scrolltop same or higher document minus window height...


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -