Hello Circle Forum!
I'm working on a client site (pw: snapple) and just added a page load animation script I found on Will Myers' teaching channel. I've used this on a couple sites with no problem, but something odd is happening here—it's causing a white gap between the top navigation and the first section (a scrolling text block). A couple of notes:
The script only works when injected into the header and not the footer.
I know the script is causing this gap because the gap disappears when I remove the script.
The script:
/*PAGE-LOADING-ANIMATION*/
<div id="wm-loading-animation">
<div class="loading-graphic">
<img src="https://static1.squarespace.com/static/643dc9e685d581353cf47af7/t/6449c9262abdc63349af337a/1682557222652/MakeSpace-animation-star.png">
</div>
</div>
<script>
function hideAnimation(){
document.querySelector("#wm-loading-animation").classList.add("hide-animation");
}
setTimeout(function(){
setTimeout(function(){
hideAnimation()
}, 500);
let checkLoad = setInterval(function(){
if (document.readyState === "complete"){
hideAnimation();
clearInterval(checkLoad)
}
}, 100);
}, 1500);
</script>
The CSS bits:
/*PAGE-LOADING-ANIMATION*/
#wm-loading-animation img{
height:150px;
width:auto;
}
#wm-loading-animation{
height:100vh;
width:100vw;
background:#fff;
position:fixed;
z-index: 99999;
display:flex;
align-items:center;
justify-content:center;
}
.wm-slider-container .dots-container{
left: unset !important;
transform: unset !important;
right: 3vw
}
@keyframes pulse{
0%{ transform:scale(1.1)}
50%{ transform:scale(0.9)}
100%{ transform:scale(1.1)}
}
.loading-graphic{
animation: pulse 3s ease-in-out infinite;
}
#wm-loading-animation.hide-animation{
visibility: hidden;
opacity: 0;
transition: visibility 0s 1s,
opacity 1s linear; /*Hide this element after load*/
}
I've added a screenshot of the gap. Has anyone else had this problem?
Many thanks to anyone who can help me solve this riddle—I'm coming up empty with my very limited (but scrappy) coding abilities.