-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
207 lines (181 loc) · 5.97 KB
/
Copy pathscript.js
File metadata and controls
207 lines (181 loc) · 5.97 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
// Mobile Navigation
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
hamburger.addEventListener('click', () => {
navLinks.style.display = navLinks.style.display === 'flex' ? 'none' : 'flex';
});
// Smooth Scrolling
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'
});
// Close mobile menu if open
if (window.innerWidth <= 768) {
navLinks.style.display = 'none';
}
}
});
});
// Form Submission
const contactForm = document.querySelector('.contact-form');
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Get form data
const formData = new FormData(this);
const formObject = {};
formData.forEach((value, key) => {
formObject[key] = value;
});
// Here you would typically send the form data to a server
// For now, we'll just show a success message
alert('Thank you for your message! We will get back to you soon.');
this.reset();
});
// Scroll Animation
const sections = document.querySelectorAll('section');
const navItems = document.querySelectorAll('.nav-links a');
window.addEventListener('scroll', () => {
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (pageYOffset >= sectionTop - 60) {
current = section.getAttribute('id');
}
});
navItems.forEach(item => {
item.classList.remove('active');
if (item.getAttribute('href').slice(1) === current) {
item.classList.add('active');
}
});
});
// Add active class to nav links
navItems.forEach(item => {
item.addEventListener('click', function() {
navItems.forEach(link => link.classList.remove('active'));
this.classList.add('active');
});
});
// Add animation to cards on scroll
const cards = document.querySelectorAll('.card');
const eventCards = document.querySelectorAll('.event-card');
const observerOptions = {
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
cards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'all 0.5s ease-out';
observer.observe(card);
});
eventCards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'all 0.5s ease-out';
observer.observe(card);
});
// Add parallax effect to hero section
window.addEventListener('scroll', () => {
const hero = document.querySelector('.hero');
const scrolled = window.pageYOffset;
hero.style.backgroundPositionY = scrolled * 0.5 + 'px';
});
// Add typing effect to hero title
function typeWriter(element, text, speed = 100) {
let i = 0;
element.innerHTML = '';
function type() {
if (i < text.length) {
element.innerHTML += text.charAt(i);
i++;
setTimeout(type, speed);
}
}
type();
}
// Initialize typing effect
const heroTitle = document.querySelector('.hero h1');
const originalText = heroTitle.textContent;
typeWriter(heroTitle, originalText);
// Add counter animation to stats
function animateValue(element, start, end, duration) {
let startTimestamp = null;
const step = (timestamp) => {
if (!startTimestamp) startTimestamp = timestamp;
const progress = Math.min((timestamp - startTimestamp) / duration, 1);
element.innerHTML = Math.floor(progress * (end - start) + start) + '+';
if (progress < 1) {
window.requestAnimationFrame(step);
}
};
window.requestAnimationFrame(step);
}
// Animate stats when they come into view
const statsObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const statItems = entry.target.querySelectorAll('.stat-item h3');
statItems.forEach(item => {
const value = parseInt(item.textContent);
animateValue(item, 0, value, 2000);
});
statsObserver.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
const statsSection = document.querySelector('.stats');
statsObserver.observe(statsSection);
// Add hover effect to program cards
const programCards = document.querySelectorAll('.card');
programCards.forEach(card => {
card.addEventListener('mouseenter', () => {
card.style.transform = 'translateY(-10px) scale(1.02)';
});
card.addEventListener('mouseleave', () => {
card.style.transform = 'translateY(0) scale(1)';
});
});
// Add smooth reveal animation to sections
const revealSection = (entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('revealed');
observer.unobserve(entry.target);
}
});
};
const sectionObserver = new IntersectionObserver(revealSection, {
threshold: 0.15
});
document.querySelectorAll('section').forEach(section => {
section.classList.add('section-hidden');
sectionObserver.observe(section);
});
// Add CSS class for section reveal animation
const style = document.createElement('style');
style.textContent = `
.section-hidden {
opacity: 0;
transform: translateY(50px);
transition: all 1s ease-out;
}
.revealed {
opacity: 1;
transform: translateY(0);
}
`;
document.head.appendChild(style);