Open adam-jones-net opened 4 years ago
Didn't see that solution there, thanks. I had a similar question and implemented a timer to trigger nextLoads to front load a couple more pages. Super hacky and dirty solution, but working.
There are some issues with browser back though. For ex. if the user browses back before the requests being made are finished on returning to the page infinite scroll won't fetch more requests (seems to be a safari issue only related to bfcache).
Logic: Initial load is 10 posts, then another trigger in js after page load every x seconds. Timer ends on last page. Works in my case since we have a finite amount of posts that will never be too large (100 etc.)
` // Auto load using timed throttle $container.on( 'append.infiniteScroll', tttjAutoLoad ); function tttjAutoLoad() {
let myInterval = setInterval(myTimer, 250);
function myTimer() {
// document.getElementById('view-more-button').click();
$container.infiniteScroll('loadNextPage');
// document.getElementById("demo").innerHTML += "Hello";
}
function myStopFunction() {
clearInterval(myInterval);
}
$container.on( 'last.infiniteScroll', myStopFunction );
};
});`
I thought at first the setting scrollThreshold might help but it doesn't seem to make much difference for me.
I thought also this suggestion may be useful but it doesn'ts eem to work on the current codebase.
Anyone have any suggestions for making the library load more results earlier?