Reputation: 3858
I have a simple slideshow, how do I go about showing some sort of load rectangle before the slideshow starts? Right now on a slow connection the slide show is kinda funky until the first image fully loads.
Upvotes: 1
Views: 854
Reputation: 490233
You could put a throbber as a background.
#slideshow {
background: url(images/loading.gif) no-repeat center center;
}
Alternatively, you could...
var images = ['a.jpg', 'b.jpg'],
imagesLoaded = 0,
totalImages = images.length;
$.each(images, function(i, image) {
var img = new Image();
img.onload = function() {
imagesLoaded++;
if (imagesLoaded == totalImages) {
// All images done
}
};
img.src = image;
});
Upvotes: 2