-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animated Preloader added #405
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,14 +15,98 @@ | |||||
|
||||||
</head> | ||||||
|
||||||
<style> | ||||||
/* Preloader styling */ | ||||||
.preloader { | ||||||
position: fixed; | ||||||
top: 0; | ||||||
left: 0; | ||||||
width: 100%; | ||||||
height: 100%; | ||||||
display: flex; | ||||||
justify-content: center; | ||||||
align-items: center; | ||||||
z-index: 50; | ||||||
background: linear-gradient(to right, #26a69a, #26a69a, #26a69a); /* Yellow gradient */ | ||||||
} | ||||||
|
||||||
/* Text animation */ | ||||||
.animate-stroke { | ||||||
text-transform: uppercase; | ||||||
animation: stroke 2.5s infinite alternate; | ||||||
stroke-width: 2; | ||||||
stroke: white; | ||||||
font-size: 70px; | ||||||
font-family: "Arial", sans-serif; | ||||||
} | ||||||
|
||||||
/* Keyframes for the stroke animation */ | ||||||
@keyframes stroke { | ||||||
0% { | ||||||
fill: #fff; | ||||||
stroke: #0b8276; | ||||||
stroke-dashoffset: 25%; | ||||||
stroke-dasharray: 0 50%; | ||||||
stroke-width: 1; | ||||||
} | ||||||
|
||||||
70% { | ||||||
fill: #fff; | ||||||
stroke: #0b8276; | ||||||
} | ||||||
|
||||||
80% { | ||||||
fill: #fff; | ||||||
stroke: #0b8276; | ||||||
stroke-width: 1; | ||||||
} | ||||||
|
||||||
100% { | ||||||
fill: #fff; | ||||||
stroke: #0b8276; | ||||||
stroke-dashoffset: -25%; | ||||||
stroke-dasharray: 50% 0; | ||||||
stroke-width: 0; | ||||||
text-shadow: 0 0 10px #fff, 0 0 15px whitesmoke; | ||||||
} | ||||||
} | ||||||
|
||||||
/* Initially hide the main content */ | ||||||
.hidden { | ||||||
display: none; | ||||||
} | ||||||
|
||||||
/* When main content is shown */ | ||||||
.main-content { | ||||||
display: block; | ||||||
padding: 20px; | ||||||
width: 100vw; | ||||||
min-height: 100vh; /* Ensure it covers at least the full height */ | ||||||
padding: 0; /* Reset any padding */ | ||||||
margin: 0; /* Remove margin */ | ||||||
} | ||||||
</style> | ||||||
<body> | ||||||
<div class="preloader"> | ||||||
<svg viewBox="0 0 1320 300"> | ||||||
<text | ||||||
x="50%" | ||||||
y="50%" | ||||||
dy=".35em" | ||||||
text-anchor="middle" | ||||||
class="animate-stroke" | ||||||
style="font-weight: bold;" | ||||||
> | ||||||
Waste Management | ||||||
</text> | ||||||
</svg> | ||||||
</div> | ||||||
|
||||||
<!-- Progress Bar --> | ||||||
|
||||||
|
||||||
<div id="progress-container"> | ||||||
<div id="progress-bar"></div> | ||||||
</div> | ||||||
<div class="main-contetnt"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix critical typo in main content class name. There's a typo in the class name that will break the preloader functionality. The JavaScript looks for - <div class="main-contetnt">
+ <div class="main-content"> 📝 Committable suggestion
Suggested change
|
||||||
<header> | ||||||
|
||||||
|
||||||
|
@@ -51,6 +135,7 @@ <h1>Waste Management</h1> | |||||
<button id="menu-toggle" aria-label="Toggle menu">☰</button> | ||||||
</div> | ||||||
</header> | ||||||
</div> | ||||||
<section class="hero"> | ||||||
<div class="hero-content"> | ||||||
<div class="hero-text"> | ||||||
|
@@ -757,6 +842,15 @@ <h3>Our Commitment to Sustainability</h3> | |||||
</script> | ||||||
<script src="https://www.chatbase.co/embed.min.js" chatbotId="wQJs3fix9gu515zxNshBF" domain="www.chatbase.co" defer> | ||||||
</script> | ||||||
<script> | ||||||
window.addEventListener('load', function() { | ||||||
// Show the preloader for 5 seconds | ||||||
setTimeout(function() { | ||||||
document.querySelector('.preloader').style.display = 'none'; // Hide preloader | ||||||
document.querySelector('.main-content').classList.remove('hidden'); // Show main content | ||||||
}, 5000); // 5 seconds delay | ||||||
}); | ||||||
Comment on lines
+846
to
+852
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve preloader timing and reliability. The current implementation has several limitations:
Consider this improved implementation: window.addEventListener('load', function() {
- // Show the preloader for 5 seconds
+ // Track actual content load state
+ const contentLoaded = new Promise((resolve) => {
+ if (document.readyState === 'complete') {
+ resolve();
+ } else {
+ window.addEventListener('load', resolve);
+ }
+ });
+
+ // Ensure minimum animation time of 2 seconds
+ const minimumDelay = new Promise(resolve => setTimeout(resolve, 2000));
+
+ // Hide preloader only when content is ready and minimum time has passed
+ Promise.all([contentLoaded, minimumDelay]).then(() => {
setTimeout(function() {
document.querySelector('.preloader').style.display = 'none';
document.querySelector('.main-content').classList.remove('hidden');
- }, 5000); // 5 seconds delay
+ }, 0);
+ });
}); Also add this fallback in the <noscript>
<style>
.preloader { display: none !important; }
.main-content { display: block !important; }
</style>
</noscript> |
||||||
</script> | ||||||
</body> | ||||||
|
||||||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate padding declaration.
The
.main-content
class has duplicate padding properties..main-content { display: block; - padding: 20px; width: 100vw; min-height: 100vh; padding: 0; margin: 0; }
📝 Committable suggestion