javascript - Jquery ajax infinite scroll exclude footer height -


i'm working on ajax infinite scroll. have below code make ajax request after scrolling @ end,

$(window).scroll(function(){ if($(window).scrolltop() >= ($(document).height() - $(window).height())){     loadlist(); } }); 

but fires when scrolled @ end (including footer.). want fired when footer starting show while scrolling (footer height 300px).

i researched , tried following code,

$(window).scroll(function(){ if($(window).scrolltop() >= ($(document).height() - $(window).height()) - 300){ // 300px footer height     loadlist(); } }); 

but seems dirty. function gets fired many times when scrolling. solutions ?

i'd take approach of triggering behaviour when footer element first scrolls view.

var $footer = $("#my-footer");  $(window).scroll( function() {     if (isscrolledintoview($footer) ) loadlist(); }); 

see check if element visible after scrolling code isscrolledintoview().


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -