I have a code that does a loading animation before starting a page.
css.css
.preload{
position: fixed;
z-index:99999;
top:0; left:0;
width:100%; height:100%;
opacity:1;
background-color:#fff;
/*background-image:url('https://38.media.tumblr.com/bec5933eea5043acf6a37bb1394384ab/tumblr_meyfxzwXUc1rgpyeqo1_400.gif');
background-image:url('https://media.giphy.com/media/ugEWbEMH0gm2c/giphy.gif');*/
background-image:url('https://media.giphy.com/media/l4FGmQ3Ddqsp8LKKY/giphy.gif');
background-size:70%;
background-position:center;
background-repeat:no-repeat;
}
index.php
<div id="preload" class="preload"></div>
script.php
<script>
$(document).ready(function(){
$("#preload").fadeOut(1000);
});
</script>
My question is this: Why when I change the .ready to. load the animation gets infinite? And why before loading all the images does the animation disappear?