I made a website using Infinite Ajax Scrolling:
<script type="text/javascript">
if($(window).width() >= 600){ //activate ias scrolling for windows bigger than 600px
var ias = $.ias({
container: "#base-container",
item: ".item",
pagination: "#pagination",
next: ".next a",
delay: 1500
});
ias.extension(new IASSpinnerExtension({ src: 'bundles/spinner.gif' }));
ias.extension(new IASTriggerExtension({ offset: 100, text: 'Load more' }));
ias.extension(new IASNoneLeftExtension({text: 'You reached the end.'}));
ias.extension(new IASPagingExtension());
ias.extension(new IASHistoryExtension({ prev: '.prev a' }));
}
</script>
It works fine but I don't like the way it renders new pages when it comes to images, making the fadein before they are ready. My solution is waiting for the images by adding a simple preloader. The problem is, of course, that it fires only once!:
<script type="text/javascript">
$(window).load(function() { // makes sure the whole site is loaded
$('#status').fadeOut(); // will first fade out the loading animation
$('#preloader').delay(350).fadeOut('slow'); // will fade out the white DIV that covers the website.
$('body').delay(350).css({'overflow':'visible'});
})
</script>
How can I preload not once, but every time a new page is appended to the body? I can't picture the solution.