I really need some suggestions on how to fire events depending on the proceed of preloading images.
On my site i have lots of large images, where the most of them are display: none
. For avoiding image flickering and co i have read this POST and the answer seems a good way for preloading to me.
But what i want to do is firing events at a specific status of preloading. Let's say i have around 40 images, and i want to fire an event at every tenth image which is already loaded, how could i handle this?
One sentence about my intention. I would like to create my own loading-screen. A little animation whose process is dependent on the process of the preloaded-images.
Something like:
first10picturesloaded(){ /* do something */ }
next10picturesloaded() { /* do something more */ }
...
Thanks in advance!
Edit: As requested this is the preload-snippet
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
$('<img/>')[0].src = this;
});
}
preload([
'img/about_1.gif',
'img/about_2.gif',
'img/contact_2.gif',
'img/contact.gif',
'img/digital_1.gif',
'img/digital_2.gif',
'img/dragged.gif',
'img/loading.gif',
'img/photo_1.gif',
'img/photo_2.gif',
'img/print_1.gif',
'img/print_2.gif',
'img/web_1.gif',
'img/web_2.gif',
'img/about.jpg']); //there are much more pictures in the array