I want to create the impression of a preloader for my site.
I have <div class="loading">
that should fade in and out until the contents of <div id=page-wrap>
are loaded.
Right now i'm using a time-based solution to guess, but of course it isn't accurate:
<script type="text/javascript">
// fade site in when loaded
$("#page-wrap").css("display", "none");
$(window).bind("load",function(){
$("#page-wrap").fadeIn(2000);
});
// blink markers
$(".loading").hide();
$(".loading").fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200);
</script>
How can I make this more sophisticated and actually bind the fadeIn/fadeOut to the page loading?