Skip to content

Commit

Permalink
Merge pull request #378 from NeerajaGurram/pre-loader
Browse files Browse the repository at this point in the history
Pre loader
  • Loading branch information
Manaregr8 authored Jul 21, 2024
2 parents 3b6c40d + 21e0267 commit 7e51a82
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Binary file added public/images/loader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 20 additions & 10 deletions server/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
display: flex;
justify-content: space-between;
align-items: center;
z-index: 999;
}
.nav__logo {
Expand Down Expand Up @@ -389,8 +390,8 @@
}
.preloader img {
height: 200px;
width: 200px;
height: 250px;
width: 250px;
border-radius: 1000px;
}
Expand Down Expand Up @@ -531,17 +532,26 @@

<body class="page-leaderboard">
<div class="preloader">
<img class="center" src="https://c.tenor.com/XasjKGMk_wAAAAAC/tenor.gif" alt="" />
<img class="center" id="loader-img" src="/images/loader.gif" alt="" />
</div>
<script>
window.addEventListener("load", () => {
const loader = document.querySelector(".preloader");
loader.classList.add("preloader--hidden");
loader.addEventListener("transitionend", () => {
document.body.removeChild(loader);
});
const loader = document.querySelector(".preloader");
// to check if the page was reloaded
if (performance.navigation.type === performance.navigation.TYPE_RELOAD) {
const loaderImg = document.getElementById("loader-img");
//to force reload
loaderImg.src = `${loaderImg.src}?t=${new Date().getTime()}`;
setTimeout(() => {
loader.classList.add("preloader--hidden");
}, 8000);
loader.addEventListener("transitionend", () => {
document.body.removeChild(loader);
});
} else {
//to remove the preloader if it is not a reload
document.body.removeChild(loader);
}
});
</script>
<!-- Body of the webpage. Background color set inline. -->
Expand Down

0 comments on commit 7e51a82

Please sign in to comment.