Skip to content

Instantly share code, notes, and snippets.

@schmolzp
Last active September 10, 2020 13:57
Show Gist options
  • Select an option

  • Save schmolzp/6504d622151eec85b4d7493c302b41f4 to your computer and use it in GitHub Desktop.

Select an option

Save schmolzp/6504d622151eec85b4d7493c302b41f4 to your computer and use it in GitHub Desktop.
Loading Screen animation
<div aria-label="Page Loading" id="loadWrap" role="complementary" style="display: none;">
<!-- Loading SVG goes here -->
</div>
var loadWrap = document.getElementById('loadWrap');
if(loadWrap) {
if ( window.location.pathname == '/' ){
if (sessionStorage.getItem("visited")) {
//Show default loader
$('.default-loader').show();
$('.home-loader').hide();
$(document).ready(function(){
$('#loadWrap').fadeOut();
setTimeout(function() {
$('body').removeClass('loading');
}, 400);
});
} else if (!sessionStorage.getItem("visited")) {
//Show home loader
$('.default-loader').hide();
$('.home-loader').show();
//Set the key: visited
sessionStorage.setItem('visited', 'true');
$(document).ready(function(){
setTimeout(function() {
$('#loadWrap').fadeOut();
}, 1300);
setTimeout(function() {
$('body').removeClass('loading');
}, 1700);
});
}
} else {
$(document).ready(function(){
$('#loadWrap').fadeOut();
setTimeout(function() {
$('body').removeClass('loading');
}, 400);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment