Skip to content

Commit f9f4225

Browse files
authored
Merge pull request #589 from ShroudAnkit53/bug-fixing
Adding a loader animation
2 parents 47d0e19 + 9b7cb61 commit f9f4225

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

index.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@
8686
</head>
8787

8888
<body>
89+
<!-- Loading Screen -->
90+
<div id="loading-screen">
91+
<div class="loader">
92+
<i class="fa-solid fa-spinner"></i>
93+
<h2>Loading<span class="dots"></span></h2>
94+
</div>
95+
</div>
8996
<a id="top"></a> <!--added for issue 260 -->
9097
<!-- ================================ Header Section Start Here ================================ -->
9198
<header>
@@ -546,5 +553,40 @@ <h5 data-aos-duration="650" data-aos="fade-left" class="footer-title">Contact Us
546553

547554
<!-- ================ Custom JS ================ -->
548555
<script src="scripts/main.js"></script>
556+
557+
<script>
558+
document.addEventListener("DOMContentLoaded", function () {
559+
const loadingScreen = document.getElementById("loading-screen");
560+
const loadingHeading = loadingScreen.querySelector("h2");
561+
562+
const sentences = [
563+
"Loading your experience...",
564+
"Almost ready, please wait..."
565+
];
566+
567+
let index = 0;
568+
loadingHeading.innerHTML = sentences[index]; // show first sentence
569+
570+
// Change sentence every 4 seconds
571+
const textInterval = setInterval(() => {
572+
index = (index + 1) % sentences.length;
573+
loadingHeading.innerHTML = sentences[index];
574+
// inside setInterval
575+
loadingHeading.classList.add("fade-out");
576+
setTimeout(() => {
577+
loadingHeading.innerHTML = sentences[index];
578+
loadingHeading.classList.remove("fade-out");
579+
}, 500);
580+
581+
}, 4000);
582+
583+
// Hide loading screen after 8 seconds
584+
setTimeout(() => {
585+
clearInterval(textInterval);
586+
loadingScreen.classList.add("hidden");
587+
}, 8000);
588+
});
589+
590+
</script>
549591
</body>
550592
</html>

styles.css

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,3 +880,84 @@ body {
880880
.icon-container i:hover {
881881
transform: scale(1.2);
882882
}
883+
884+
/*Loading page*/
885+
#loading-screen {
886+
position: fixed;
887+
top: 0;
888+
left: 0;
889+
width: 100%;
890+
height: 100vh;
891+
background: white;
892+
color: blue;
893+
display: flex;
894+
justify-content: center;
895+
align-items: center;
896+
z-index: 9999;
897+
transition: opacity 0.5s ease, visibility 0.5s ease;
898+
}
899+
900+
#loading-screen.hidden {
901+
opacity: 0;
902+
visibility: hidden;
903+
}
904+
905+
#loading-screen h2 {
906+
transition: opacity 0.5s ease-in-out;
907+
}
908+
909+
.fade-out {
910+
opacity: 0;
911+
}
912+
913+
914+
.loader {
915+
text-align: center;
916+
}
917+
918+
.loader i {
919+
font-size: 4.5rem;
920+
animation: spin 2s linear infinite;
921+
}
922+
923+
.loader h2 {
924+
margin-top: 1.5rem;
925+
font-size: 2.1rem;
926+
}
927+
928+
.dots::after {
929+
content: "";
930+
display: inline-block;
931+
animation: dots 1.5s steps(5, end) infinite;
932+
}
933+
934+
@keyframes dots {
935+
0% {
936+
content: "";
937+
}
938+
20% {
939+
content: ".";
940+
}
941+
40% {
942+
content: "..";
943+
}
944+
60% {
945+
content: "...";
946+
}
947+
80%{
948+
content: "....";
949+
}
950+
100% {
951+
content: "";
952+
}
953+
}
954+
955+
/* Spin Animation */
956+
@keyframes spin {
957+
from {
958+
transform: rotate(0deg);
959+
}
960+
to {
961+
transform: rotate(360deg);
962+
}
963+
}

0 commit comments

Comments
 (0)