-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
240 lines (189 loc) · 7.62 KB
/
script.js
File metadata and controls
240 lines (189 loc) · 7.62 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
document.addEventListener('DOMContentLoaded', function() {
const menuIcon = document.querySelector('.menu-icon');
const navLinks = document.querySelector('.nav-links');
menuIcon.addEventListener('click', function() {
navLinks.classList.toggle('active');
});
});
// Carousel functionality
document.addEventListener('DOMContentLoaded', () => {
const carouselContainer = document.querySelector('.carousel-container');
const slides = document.querySelectorAll('.carousel-slide');
const indicators = document.querySelector('.carousel-indicators');
let currentIndex = 0;
const totalSlides = slides.length;
// Create indicators dynamically
for (let i = 0; i < totalSlides; i++) {
const indicator = document.createElement('div');
indicator.classList.add('carousel-indicator');
if (i === 0) indicator.classList.add('active');
indicators.appendChild(indicator);
indicator.addEventListener('click', () => {
goToSlide(i);
});
}
const allIndicators = document.querySelectorAll('.carousel-indicator');
function goToSlide(index) {
currentIndex = index;
updateCarousel();
}
function updateCarousel() {
carouselContainer.style.transform = `translateX(-${currentIndex * 100}%)`;
allIndicators.forEach((indicator, i) => {
indicator.classList.toggle('active', i === currentIndex);
});
}
function showNextSlide() {
currentIndex = (currentIndex + 1) % totalSlides;
updateCarousel();
}
function showPreviousSlide() {
currentIndex = (currentIndex - 1 + totalSlides) % totalSlides;
updateCarousel();
}
// Auto-slide every 3 seconds
let autoSlide = setInterval(showNextSlide, 3000);
// Pause on hover
carouselContainer.addEventListener('mouseenter', () => clearInterval(autoSlide));
carouselContainer.addEventListener('mouseleave', () => autoSlide = setInterval(showNextSlide, 3000));
// Navigation buttons
const nextBtn = document.querySelector('.carousel-next');
const prevBtn = document.querySelector('.carousel-prev');
if (nextBtn && prevBtn) {
nextBtn.addEventListener('click', showNextSlide);
prevBtn.addEventListener('click', showPreviousSlide);
}
});
// Floating button functionality
const floatingBtn = document.querySelector('.floating-btn');
floatingBtn.addEventListener('click', () => {
window.location.href = '#events'; // Navigate to the events section
});
document.getElementById("emailLink").addEventListener("click", function(e) {
e.preventDefault(); // Prevents the default action (navigation)
window.location.href = "mailto:contact@college.com"; // Opens the default email client with the specified email address
});
ScrollReveal({
reset: true, //this is for the resting the animation when we scrolled down
distance: '60px',
duration: 2500,
delay: 400
});
ScrollReveal().reveal('.container h1' , { delay: 500 ,origin: 'top'});
ScrollReveal().reveal('.container p' , { delay: 600 ,origin: 'right'});
ScrollReveal().reveal('.events-heading ' , { delay: 500 ,origin: 'left'});
ScrollReveal().reveal('.slider ' , { delay: 600 ,origin: 'bottom'});
ScrollReveal().reveal('.exp_btn ' , { delay: 700 });
ScrollReveal().reveal('.stat_bars1 ' , { delay: 500 ,origin: 'left'});
ScrollReveal().reveal('.stat_bars2 ' , { delay: 600 ,origin: 'left'});
ScrollReveal().reveal('.stat_bars3 ' , { delay: 700 ,origin: 'left'});
ScrollReveal().reveal('.stats p ' , { delay: 500 ,origin: 'left'});
// countdown part
const targetDate = new Date("2025-02-27T08:59:59").getTime();
function updateCountdown() {
const now = new Date().getTime();
const distance = targetDate - now;
if (distance <= 0) {
document.getElementById("countdown").innerHTML = "Time's up!";
clearInterval(countdownInterval);
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);
document.getElementById("days").textContent = days;
document.getElementById("hours").textContent = hours;
document.getElementById("minutes").textContent = minutes;
document.getElementById("seconds").textContent = seconds;
}
// Update the countdown every 1 second
const countdownInterval = setInterval(updateCountdown, 1000);
updateCountdown(); // Initial call to set the countdown immediately
// this is for the animated video section
// const section = document.querySelector('section.vid')
// const vid = section.querySelector('video')
// vid.pause()
// const scroll = () => {
// const distance = window.scrollY - section.offsetTop
// const total = section.clientHeight - window.innerHeight
// let percentage = distance/total
// percentage = Math.max(0, percentage)
// percentage = Math.min(percentage, 1)
// if(vid.duration > 0){
// vid.currentTime = vid.duration * percentage
// }
// }
// scroll()
// window.addEventListener("scroll",scroll)
// refer this for queries
// https://www.youtube.com/watch?v=L1eu737bu70
const container = document.querySelector('.animation-container');
function createParticle() {
const particle = document.createElement('div');
particle.className = 'particle';
const x = Math.random() * 100;
const y = Math.random() * 100;
const duration = 1 + Math.random() * 2;
particle.style.left = `${x}%`;
particle.style.top = `${y}%`;
particle.style.animation = `float ${duration}s ease-in-out infinite`;
container.appendChild(particle);
setTimeout(() => {
container.removeChild(particle);
}, duration * 1000);
}
setInterval(createParticle, 500);
// Navbar scroll behavior
window.addEventListener('scroll', function() {
const navbar = document.querySelector('.nav-bar');
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Team page scroll animations
document.addEventListener('DOMContentLoaded', () => {
const committeeSections = document.querySelectorAll('.committee-section');
const memberCards = document.querySelectorAll('.member-card');
// Set initial card indices for staggered animations
memberCards.forEach((card, index) => {
card.style.setProperty('--card-index', index % 2);
});
// Intersection Observer for committee sections
const sectionObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, {
threshold: 0.2
});
committeeSections.forEach(section => {
sectionObserver.observe(section);
});
// Smooth scroll for navigation
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Mobile menu toggle
const menuButton = document.querySelector('.menu-button');
const navLinks = document.querySelector('.nav-links');
if (menuButton && navLinks) {
menuButton.addEventListener('click', () => {
navLinks.classList.toggle('active');
menuButton.classList.toggle('active');
});
}
});