Preloading a folder with images [closed]

-5

Is there any way to preload a folder with images instead of preloading image by image with javascript? Well I will have a folder with several images that will be played by a database.

    
asked by anonymous 29.03.2016 / 18:55

1 answer

2

Well come on,

Hypothetical situation,

You have a div, where you will put your images,

Let's imagine:

<div class='preload'><img src='urlimagem'></div>

In this case, when loading your page you will make the images available in this div, leaving the preload with a "display: none" attribute

When the client clicks on +, you can leave a load gif for example:

$('.botaoMais').click(function(){
   $('.espacoCarregamento').html('gif de loading');
   var controle = true;
   $('.preload').each(function(){
      if($(this,'img').complete == false){
         controle = false;
      }
   });
   if(controle == true){
   //display block na div das imagens.
   }
   }
});

This is to give display block when you have loaded everything, but could go on giving 1 by 1 as it is loaded.

I think it's + - that.

But this is kind of complex because you have to keep holding the execution until it loads, I think the easiest way is to use this lib:

link

    
29.03.2016 / 20:19