Reputation: 133
I've been working on a website and I recently decided to implement a preloader to my website. I have everything in place but the JavaScript to control the loader does not seem to work.
Here's my code:
As there's quite some code, I have uploaded it on JSFiddle Here it is https://jsfiddle.net/mvc2fe1a/1/
<div class="spinner-wrapper">
<div class="spinner">
<svg width="634" height="62" viewBox="0 0 634 62" fill="none" xmlns="http://www.w3.org/2000/svg">
...
</svg>
</div>
</div>
.spinner-wrapper {
height: 100%;
width: 100%;
background: #333;
position: absolute;
top: 0;
left: 0;
}
.spinner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
function loadPage() {
let timeout = setTimeout(showPage, 3000);
}
function showPage() {
document.querySelector('.spinner-wrapper').style.display = 'none'
document.querySelector('.container').style.display = 'block'
}
However this code does not work, what am I doing wrong?
Upvotes: 1
Views: 617
Reputation: 21675
You need to call your loadPage
function. Right now, you have only defined it.
// other code
loadPage();
Upvotes: 2
Reputation: 1693
You forgot to call the loadPage()
function
I edited your Fiddle: https://jsfiddle.net/woma7h83/
Upvotes: 0