jquery - Each Function to Select Current page in Infinite Scroll -
jquery - Each Function to Select Current page in Infinite Scroll -
i've set in little bit of jquery site loads , appends next page when near bottom of current page. want observe user on page can modify url history.pushstate().
each page wrapped in 'load-part' class.
var load_number; var start_offset; var end_offset; // run function on each page $('.load-part').each(function() { // page number load_number = parseint($(this).attr('id').replace("load-part-","")); // true top offset of page start_offset = $(this).children().first().offset().top; // true bottom offset of page end_offset = $(this).children().last().offset().top + window_height; // if window between limits - i.e. on page if (start_offset <= $(window).scrolltop() < end_offset) { // update url current page number history.pushstate(null, null, load_number) } });
the problem i'm getting if statement seems evaluating true regardless, when window.scrolltop() value doesn't fall between limits. doing wrong??
if (start_offset <= $(window).scrolltop() && $(window).scrolltop() < end_offset) { // update url current page number history.pushstate(null, null, load_number) }
is more javascript-enabled
jquery ajax infinite-scroll pushstate
Comments
Post a Comment