-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
90 lines (77 loc) · 3.36 KB
/
Copy pathscript.js
File metadata and controls
90 lines (77 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
document.addEventListener('DOMContentLoaded', () => {
// Navbar Scroll Effect
const navbar = document.getElementById('navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Mobile Menu Toggle
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navLinks.classList.toggle('active');
});
// Close mobile menu when clicking a link
document.querySelectorAll('.nav-links a').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navLinks.classList.remove('active');
});
});
// Intersection Observer for Scroll Animations
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.15
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
if (entry.target.classList.contains('fade-up')) {
entry.target.classList.add('fade-in');
} else if (entry.target.classList.contains('fade-left')) {
entry.target.classList.add('fade-in-left');
}
observer.unobserve(entry.target); // Optional: animate only once
}
});
}, observerOptions);
// Observe elements
document.querySelectorAll('.fade-up, .fade-left').forEach(el => {
observer.observe(el);
});
// Add staggered delay to title letters
const letters = document.querySelectorAll('.title-kaleidoscope span');
letters.forEach((letter, index) => {
letter.style.animationDelay = `${index * 0.1}s`;
});
// Countdown Timer logic
const countDownDate = new Date("Oct 24, 2026 09:00:00").getTime();
// Update the count down every 1 second
const countdownInterval = setInterval(function() {
const now = new Date().getTime();
const distance = countDownDate - now;
const daysEl = document.getElementById("days");
if (!daysEl) return; // Exit if not on page with countdown
if (distance < 0) {
clearInterval(countdownInterval);
daysEl.innerHTML = "00";
document.getElementById("hours").innerHTML = "00";
document.getElementById("minutes").innerHTML = "00";
document.getElementById("seconds").innerHTML = "00";
return;
}
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
daysEl.innerHTML = days < 10 ? '0' + days : days;
document.getElementById("hours").innerHTML = hours < 10 ? '0' + hours : hours;
document.getElementById("minutes").innerHTML = minutes < 10 ? '0' + minutes : minutes;
document.getElementById("seconds").innerHTML = seconds < 10 ? '0' + seconds : seconds;
}, 1000);
});