-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
323 lines (270 loc) · 10.1 KB
/
main.js
File metadata and controls
323 lines (270 loc) · 10.1 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
const menuBtn = document.getElementById("menu-btn");
const navLinks = document.getElementById("nav-links");
const menuBtnIcon = menuBtn.querySelector("i");
menuBtn.addEventListener("click", (e) => {
const isOpen = navLinks.classList.contains("open");
menuBtnIcon.setAttribute("class", isOpen ? "ri-menu-line" : "ri-close-line");
if (isOpen) {
navLinks.classList.add("close");
navLinks.addEventListener(
"animationend",
(e) => {
navLinks.classList.remove("open");
navLinks.classList.remove("close");
},
{ once: true }
);
} else {
navLinks.classList.add("open");
}
});
navLinks.addEventListener("click", (e) => {
navLinks.classList.remove("open");
menuBtnIcon.setAttribute("class", "ri-menu-line");
});
window.addEventListener('scroll', function() {
var navbar = document.getElementById('navbar');
var scrollPosition = window.scrollY;
if (scrollPosition > 50) {
navbar.style.backgroundColor = 'rgba(49, 54, 63, 1)';
} else {
navbar.style.backgroundColor = 'rgba(4,9,10,0.3)';
}
});
const scrollRevealOption = {
distance: "50px",
origin: "bottom",
duration: 1000,
};
ScrollReveal().reveal(".header__container .section__subheader", {
...scrollRevealOption,
});
ScrollReveal().reveal(".header__container .section__header", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".header__container .title__discription", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".header__container .time", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".header__container .countdown", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".header__container .scroll__btn", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".header__container .header__socials", {
...scrollRevealOption,
origin: "left",
delay: 1000,
});
ScrollReveal().reveal(".intro__container .intro__border", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".schedule__intro .section__subheader", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".schedule__intro .section__header", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".schedule__timeline .schedule__icons", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".timeline .content", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".register__container .register__border", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".about__image-1, .about__image-3", {
...scrollRevealOption,
origin: "right",
});
ScrollReveal().reveal(".about__image-2", {
...scrollRevealOption,
origin: "left",
});
ScrollReveal().reveal(".about__content .section__subheader", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".about__content .section__header", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".about__content p", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".about__content .about__btn", {
...scrollRevealOption,
delay: 1000,
});
ScrollReveal().reveal(".slider__container .section__subheader", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".slider__container .section__header", {
...scrollRevealOption,
delay: 500,
});
ScrollReveal().reveal(".slider__container .slider-wrapper", {
...scrollRevealOption,
delay: 1000,
});
// intro animation
var section = document.querySelector('#intro');
var images = [
"./assets/back1.jpg",
"./assets/back2.png",
"./assets/back3.png"
];
// Preload images
var imageObjects = [];
var loadedCount = 0;
images.forEach(function(imageUrl) {
var img = new Image();
img.onload = function() {
loadedCount++;
if (loadedCount === images.length) {
// Start the interval once all images are loaded
startInterval();
}
};
img.src = imageUrl;
imageObjects.push(img);
});
function startInterval() {
var index = 0;
setInterval(function() {
index = (index + 1) % images.length;
var bg = "url('" + images[index] + "')";
section.style.transition = "background 0.7s ease"; // Smooth transition effect
section.style.background = bg;
section.style.backgroundSize = "cover"; // Make the background image cover the section
}, 5000); // Change image every 3 seconds
}
document.addEventListener("DOMContentLoaded", function() {
// Set the date we're counting down to
const countDownDate = new Date("May 1, 2025 00:00:00").getTime();
// Update the countdown every 1 second
const countdownTimer = setInterval(function() {
// Get the current date and time
const now = new Date().getTime();
// Find the distance between now and the count down date
const distance = countDownDate - now;
// Calculate time units
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);
// Display the result in the elements with respective IDs
document.getElementById("days").innerHTML = days;
document.getElementById("hours").innerHTML = hours;
document.getElementById("minutes").innerHTML = minutes;
document.getElementById("seconds").innerHTML = seconds;
// If the countdown is over, write some text
if (distance < 0) {
clearInterval(countdownTimer);
document.getElementById("days").innerHTML = '0';
document.getElementById("hours").innerHTML = '0';
document.getElementById("minutes").innerHTML = '0';
document.getElementById("seconds").innerHTML = '0';
}
}, 1000);
});
const accordionContent = document.querySelectorAll(".accordion-content");
accordionContent.forEach((item, index) => {
let header = item.querySelector("problem");
header.addEventListener("click", () =>{
item.classList.toggle("open");
let description = item.querySelector(".description");
if(item.classList.contains("open")){
description.style.height = `${description.scrollHeight}px`; //scrollHeight property returns the height of an element including padding , but excluding borders, scrollbar or margin
item.querySelector("i").classList.replace("ri-add-line", "ri-subtract-line");
}else{
description.style.height = "0px";
item.querySelector("i").classList.replace("ri-subtract-line", "ri-add-line");
}
removeOpen(index); //calling the funtion and also passing the index number of the clicked header
})
})
function removeOpen(index1){
accordionContent.forEach((item2, index2) => {
if(index1 != index2){
item2.classList.remove("open");
let des = item2.querySelector(".description");
des.style.height = "0px";
item2.querySelector("i").classList.replace("ri-subtract-line", "ri-add-line");
}
})
}
const initSlider = () => {
const imageList = document.querySelector(".slider-wrapper .image-list");
const slideButtons = document.querySelectorAll(".slider-wrapper .slide-button");
const sliderScrollbar = document.querySelector(".slider__container .slider-scrollbar");
const scrollbarThumb = sliderScrollbar.querySelector(".scrollbar-thumb");
const maxScrollLeft = imageList.scrollWidth - imageList.clientWidth;
// Handle scrollbar thumb drag
scrollbarThumb.addEventListener("mousedown", (e) => {
const startX = e.clientX;
const thumbPosition = scrollbarThumb.offsetLeft;
const maxThumbPosition = sliderScrollbar.getBoundingClientRect().width - scrollbarThumb.offsetWidth;
// Update thumb position on mouse move
const handleMouseMove = (e) => {
const deltaX = e.clientX - startX;
const newThumbPosition = thumbPosition + deltaX;
// Ensure the scrollbar thumb stays within bounds
const boundedPosition = Math.max(0, Math.min(maxThumbPosition, newThumbPosition));
const scrollPosition = (boundedPosition / maxThumbPosition) * maxScrollLeft;
scrollbarThumb.style.left = `${boundedPosition}px`;
imageList.scrollLeft = scrollPosition;
}
// Remove event listeners on mouse up
const handleMouseUp = () => {
document.removeEventListener("mousemove", handleMouseMove);
document.removeEventListener("mouseup", handleMouseUp);
}
// Add event listeners for drag interaction
document.addEventListener("mousemove", handleMouseMove);
document.addEventListener("mouseup", handleMouseUp);
});
// Slide images according to the slide button clicks
slideButtons.forEach(button => {
button.addEventListener("click", () => {
const direction = button.id === "prev-slide" ? -1 : 1;
const scrollAmount = imageList.clientWidth * direction;
imageList.scrollBy({ left: scrollAmount, behavior: "smooth" });
});
});
// Show or hide slide buttons based on scroll position
const handleSlideButtons = () => {
slideButtons[0].style.display = imageList.scrollLeft <= 0 ? "none" : "flex";
slideButtons[1].style.display = imageList.scrollLeft >= maxScrollLeft ? "none" : "flex";
}
// Update scrollbar thumb position based on image scroll
const updateScrollThumbPosition = () => {
const scrollPosition = imageList.scrollLeft;
const thumbPosition = (scrollPosition / maxScrollLeft) * (sliderScrollbar.clientWidth - scrollbarThumb.offsetWidth);
scrollbarThumb.style.left = `${thumbPosition}px`;
}
// Call these two functions when image list scrolls
imageList.addEventListener("scroll", () => {
updateScrollThumbPosition();
handleSlideButtons();
});
}
window.addEventListener("resize", initSlider);
window.addEventListener("load", initSlider);