jquery - Wait Until Infinite Scroll Finishes Loading - Javascript -


i'm working "infinite scroll" page calls 40 elements @ time when user scrolls bottom of page. how detect moment @ content of recent set has been loaded?

this works initial page load:

$(window).load(function() {     // }); 

is there similar when there's "load" long after page has been done loading?

sorry if repeat of question. unable find solution anywhere else.

after more digging around, i've used variation of question/answer.

my end result looks this:

function ($container, previouscount, callback) {     var _imgs = $container.find('img'),         _newimages = _imgs.slice(previouscount), // 'start index' new images         imgcount = _newimages.length, // count how many new ones exist         counter = 0;      _imgs.on('load', function() { // count loaded         runcallback(20, callback);     }).on('error', function() { // count errors, anyway, reach total         runcallback(20, callback);     });      function runcallback(counterlimit, callback) {         // if counter meets new count or hits counter limit, run callback         counter++;         if (counter == imgcount || counter == counterlimit) {             callback();         }     } } 

some quirks why needed way. previouscount can greater total number of images in dom, because people can jump throughout different portions of infinite scroll. because of this, there's check counter == counterlimit.

also, need run script when new set of images done loading, regardless of whether succeeded or failed. why i'm using, both, .on('load' , .on('error' run count. noticed image can error out (which fine in particular case) , throw off count , never fire callback.

==================

edit 04/27/16: i've since discovered plugin can handle , seems work (with exception of several subsequent loads before previous load done loading). check out imagesloaded.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -