I am currently using jQuery "addClass" and "removeClass" to remove the preloader. I want the preloader page to be removed when all web content is loaded. Setting a timeout function seems to work fine but I cannot seem to get to do the same when the entire site is finished loading, as in real time loading. Some help is highly appreciated.
//..HTML..//
<div class="loader-wrapper">
</div>
//..CSS..//
.loader-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.loaded .loader-wrapper {
-webkit-transform: translateY(120%);
-ms-transform: translateY(120%);
transform: translateY(120%);
-webkit-transition: all 1s 0.5s ease-out;
transition: all 1s 0.5s ease-out;
}
//..jQuery..//
<script>
$("body").removeClass('loaded');
</script>
<script>
$( window ).load(function() {
$("body").addClass('loaded');
});
</script>
//..For reference this works perfectly..//
<script>
$(document).ready(function() {
setTimeout(function() {
$("body").addClass('loaded');
}, 1800)
});
</script>