Spaces:
Running
Running
Create script.js
Browse files
script.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener('DOMContentLoaded', function () {
|
| 2 |
+
// Smooth scrolling for anchor links
|
| 3 |
+
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
| 4 |
+
anchor.addEventListener('click', function (e) {
|
| 5 |
+
e.preventDefault();
|
| 6 |
+
const targetId = this.getAttribute('href').substring(1); // Extract the target ID
|
| 7 |
+
const target = document.getElementById(targetId);
|
| 8 |
+
if (target) {
|
| 9 |
+
target.scrollIntoView({
|
| 10 |
+
behavior: 'smooth',
|
| 11 |
+
block: 'start'
|
| 12 |
+
});
|
| 13 |
+
}
|
| 14 |
+
});
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
// Add animation on scroll for service cards
|
| 18 |
+
const observer = new IntersectionObserver((entries) => {
|
| 19 |
+
entries.forEach(entry => {
|
| 20 |
+
if (entry.isIntersecting) {
|
| 21 |
+
entry.target.style.opacity = '1';
|
| 22 |
+
entry.target.style.transform = 'translateY(0)';
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
}, {
|
| 26 |
+
threshold: 0.1
|
| 27 |
+
});
|
| 28 |
+
|
| 29 |
+
document.querySelectorAll('.service-card').forEach(card => {
|
| 30 |
+
card.style.opacity = '0';
|
| 31 |
+
card.style.transform = 'translateY(20px)';
|
| 32 |
+
card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
|
| 33 |
+
observer.observe(card);
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
// Hero text fade-in animation
|
| 37 |
+
const heroTitle = document.querySelector('.hero h1');
|
| 38 |
+
const heroParagraph = document.querySelector('.hero p');
|
| 39 |
+
|
| 40 |
+
heroTitle.style.opacity = '0';
|
| 41 |
+
heroParagraph.style.opacity = '0';
|
| 42 |
+
heroTitle.style.transform = 'translateY(20px)';
|
| 43 |
+
heroParagraph.style.transform = 'translateY(20px)';
|
| 44 |
+
|
| 45 |
+
setTimeout(() => {
|
| 46 |
+
heroTitle.style.transition = 'opacity 1s ease, transform 1s ease';
|
| 47 |
+
heroParagraph.style.transition = 'opacity 1s ease 0.5s, transform 1s ease 0.5s';
|
| 48 |
+
heroTitle.style.opacity = '1';
|
| 49 |
+
heroTitle.style.transform = 'translateY(0)';
|
| 50 |
+
heroParagraph.style.opacity = '1';
|
| 51 |
+
heroParagraph.style.transform = 'translateY(0)';
|
| 52 |
+
}, 500); // Delay to allow page load
|
| 53 |
+
|
| 54 |
+
// Dark mode toggle functionality
|
| 55 |
+
const darkModeToggle = document.getElementById('dark-mode-toggle');
|
| 56 |
+
|
| 57 |
+
darkModeToggle.addEventListener('click', function (e) {
|
| 58 |
+
e.preventDefault();
|
| 59 |
+
document.body.classList.toggle('dark-mode');
|
| 60 |
+
});
|
| 61 |
+
});
|