Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As long as the "loading..." image is positioned before any other html elements, it should load first. This of course depends on the size of the image. You could put the loading div right after the tag and position it using 'position:absolute'. Regarding the code to remove the loading screen, one method is to do the following. </p> <ul> <li>Put all the images, scripts that need to be loaded in a hidden div (display: none)</li> <li>Set up a variable that will hold the total of the images / scripts to be loaded</li> <li>Set up a counter variable</li> <li>Attach to each image / script the "onload" event</li> <li>Everytime the "onload" event is triggered it will call a function that will increment the counter variable and check if the value of the counter equals the value of the total variable</li> <li>If all resources have been loaded, fire a custom event that will show the div with the images, and hide the div with the loading screen.</li> </ul> <p>The code below isn't testes so it might not work. Hope it helps</p> <pre><code>var totalImages = 0; var loadCounter = 0; function incrementLoadCounter() { loadCounter++; if(loadCounter === totalImages) { $(document).trigger('everythingLoaded'); } } function hideLoadingScreen() { $('#loadingScreen').hide(); $('#divWithImages').show(); } $(document).ready(function(e) { $('#loadingScreen').bind('everythingLoaded', function(e) { hideLoadingScreen(); }); var imagesToLoad = $('img.toLoad'); totalImages = imagesToLoad.length; $.each(imagesToLoad, function(i, item) { $(item).load(function(e) { incrementLoadCounter(); }) }); }) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload