javascriptjqueryscrolllazy-loading

Code on scroll event is not executing if window is zoomed in/out in chrome


I'm using below script to load data when scroll reaches bottom of the page. it's working fine with all the browsers except chrome. In chrome when i manually zoom in / zoom out window using keyboard shortcuts Ctr+ or Ctrl-(> or < default zoom ) it doesn't work properly.

if (($(window).scrollTop() + $(window).innerHeight()) >= $(document).height()){ 
    loadData();
 }

Solution

  • This seems to be a bug in chrome and i have reported this here>>

    i made it working by applying a small height reduction (-100) to satisfy the condition little early before it reaches the scroll end.

    code goes like this,

    if (($(window).scrollTop() + $(window).innerHeight()) >= $(document).height()-100){ 
        loadData();
     }
    

    EDIT

    Chrome developers gives following suggestion in the bug linked above.

    $(window).scrollTop() + $(window).height() >= $(document).height()