-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
284 lines (249 loc) · 9.5 KB
/
script.js
File metadata and controls
284 lines (249 loc) · 9.5 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
// Navigation functionality
document.addEventListener('DOMContentLoaded', function() {
const hamburger = document.getElementById('hamburger');
const navMenu = document.getElementById('nav-menu');
if (hamburger && navMenu) {
hamburger.addEventListener('click', function() {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
// Close menu when clicking on a link
document.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
});
});
// Close menu when clicking outside
document.addEventListener('click', function(e) {
if (!hamburger.contains(e.target) && !navMenu.contains(e.target)) {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
}
});
}
// Smooth scrolling for anchor links
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'
});
}
});
});
// AOS Animation Observer
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('aos-animate');
}
});
}, observerOptions);
// Observe all elements with data-aos attribute
document.querySelectorAll('[data-aos]').forEach(el => {
observer.observe(el);
});
// Parallax effect for hero section
window.addEventListener('scroll', function() {
const scrolled = window.pageYOffset;
const hero = document.querySelector('.hero');
if (hero) {
hero.style.transform = `translateY(${scrolled * 0.5}px)`;
}
});
// Counter animation for accuracy numbers
function animateCounter(element, target, duration = 2000) {
let start = 0;
const increment = target / (duration / 16);
function updateCounter() {
start += increment;
if (start < target) {
element.textContent = Math.floor(start) + '%';
requestAnimationFrame(updateCounter);
} else {
element.textContent = target + '%';
}
}
updateCounter();
}
// Trigger counter animation when accuracy circles are visible
const accuracyObserver = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
const numberElement = entry.target.querySelector('.accuracy-number');
if (numberElement && !numberElement.dataset.animated) {
const targetValue = parseFloat(numberElement.textContent);
numberElement.textContent = '0%';
setTimeout(() => {
animateCounter(numberElement, targetValue);
}, 500);
numberElement.dataset.animated = 'true';
}
}
});
}, { threshold: 0.5 });
document.querySelectorAll('.accuracy-circle').forEach(circle => {
accuracyObserver.observe(circle);
});
// Dynamic background particles
function createParticle() {
const particle = document.createElement('div');
particle.className = 'particle';
particle.style.cssText = `
position: fixed;
width: 2px;
height: 2px;
background: rgba(0, 255, 255, 0.7);
border-radius: 50%;
pointer-events: none;
z-index: 1;
left: ${Math.random() * 100}vw;
top: 100vh;
animation: floatUp ${3 + Math.random() * 4}s linear forwards;
`;
document.body.appendChild(particle);
// Remove particle after animation
setTimeout(() => {
if (particle.parentNode) {
particle.parentNode.removeChild(particle);
}
}, 7000);
}
// Add CSS for particle animation
if (!document.getElementById('particle-styles')) {
const style = document.createElement('style');
style.id = 'particle-styles';
style.textContent = `
@keyframes floatUp {
to {
transform: translateY(-100vh) translateX(${Math.random() * 200 - 100}px);
opacity: 0;
}
}
`;
document.head.appendChild(style);
}
// Create particles periodically
setInterval(createParticle, 2000);
// Typing effect for 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();
}
// Apply typing effect to hero title on page load
const heroTitle = document.querySelector('.hero-title');
if (heroTitle) {
const originalText = heroTitle.textContent;
setTimeout(() => {
typeWriter(heroTitle, originalText, 50);
}, 1000);
}
// Add hover effects to cards
document.querySelectorAll('.overview-card, .model-card, .team-member').forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-10px) scale(1.02)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
// Dynamic chart animation for learning curve
const svgPaths = document.querySelectorAll('.learning-curve path');
svgPaths.forEach((path, index) => {
const length = path.getTotalLength();
path.style.strokeDasharray = length;
path.style.strokeDashoffset = length;
setTimeout(() => {
path.style.transition = 'stroke-dashoffset 3s ease-in-out';
path.style.strokeDashoffset = 0;
}, index * 1000);
});
// Scroll progress indicator
function updateScrollProgress() {
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
const scrollHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
const progress = (scrollTop / scrollHeight) * 100;
let progressBar = document.querySelector('.scroll-progress');
if (!progressBar) {
progressBar = document.createElement('div');
progressBar.className = 'scroll-progress';
progressBar.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 0%;
height: 3px;
background: linear-gradient(90deg, #00ffff, #00ff88);
z-index: 10001;
transition: width 0.1s ease;
`;
document.body.appendChild(progressBar);
}
progressBar.style.width = progress + '%';
}
window.addEventListener('scroll', updateScrollProgress);
// Lazy loading for images
if ('IntersectionObserver' in window) {
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
img.classList.remove('lazy');
observer.unobserve(img);
}
});
});
document.querySelectorAll('img[data-src]').forEach(img => {
imageObserver.observe(img);
});
}
});
// Performance optimization: Debounce scroll events
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Apply debounce to scroll events
const debouncedScrollHandler = debounce(() => {
// Any scroll-based animations can be added here
}, 16); // 60fps
// FAQ functionality
document.querySelectorAll('.faq-question').forEach(question => {
question.addEventListener('click', function() {
const faqItem = this.parentElement;
const isActive = faqItem.classList.contains('active');
// Close all FAQ items
document.querySelectorAll('.faq-item').forEach(item => {
item.classList.remove('active');
});
// Open clicked item if it wasn't already active
if (!isActive) {
faqItem.classList.add('active');
}
});
});
window.addEventListener('scroll', debouncedScrollHandler);