-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
698 lines (590 loc) · 22.4 KB
/
app.js
File metadata and controls
698 lines (590 loc) · 22.4 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
// Cosmolux Interactive Features with Full-Screen Sections and Dynamic Transitions
document.addEventListener('DOMContentLoaded', function() {
// Initialize all interactive features
initFullScreenNavigation();
initSectionTransitions();
initAccordion();
initTeamCarousel();
initScrollEffects();
initNavigationEffects();
initDynamicBackgrounds();
});
// Full-Screen Section Navigation
function initFullScreenNavigation() {
const sections = document.querySelectorAll('.section');
const navLinks = document.querySelectorAll('.nav-link');
let currentSection = 0;
let isTransitioning = false;
// Section mapping
const sectionMap = {
'#home': 0,
'#orrery': 1,
'#about': 2,
'#team': 3
};
// Navigation click handlers
navLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
if (isTransitioning) return;
const targetHref = this.getAttribute('href');
const targetIndex = sectionMap[targetHref];
if (targetIndex !== undefined && targetIndex !== currentSection) {
navigateToSection(targetIndex);
}
});
});
// Scroll-based navigation
let ticking = false;
window.addEventListener('scroll', () => {
if (!ticking && !isTransitioning) {
requestAnimationFrame(() => {
updateActiveSection();
ticking = false;
});
ticking = true;
}
});
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (isTransitioning) return;
if (e.key === 'ArrowDown' || e.key === 'PageDown') {
e.preventDefault();
if (currentSection < sections.length - 1) {
navigateToSection(currentSection + 1);
}
} else if (e.key === 'ArrowUp' || e.key === 'PageUp') {
e.preventDefault();
if (currentSection > 0) {
navigateToSection(currentSection - 1);
}
}
});
function navigateToSection(targetIndex) {
if (targetIndex < 0 || targetIndex >= sections.length) return;
isTransitioning = true;
currentSection = targetIndex;
// Trigger transition effect
triggerSectionTransition(() => {
// Scroll to target section
sections[targetIndex].scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Update navigation state
updateNavigation(targetIndex);
setTimeout(() => {
isTransitioning = false;
}, 800);
});
}
function updateActiveSection() {
const scrollPosition = window.scrollY + window.innerHeight / 2;
sections.forEach((section, index) => {
const sectionTop = section.offsetTop;
const sectionBottom = sectionTop + section.offsetHeight;
if (scrollPosition >= sectionTop && scrollPosition <= sectionBottom) {
if (currentSection !== index) {
currentSection = index;
updateNavigation(index);
}
}
});
}
function updateNavigation(activeIndex) {
navLinks.forEach((link, index) => {
link.classList.remove('active');
});
const sectionKeys = Object.keys(sectionMap);
const activeHref = sectionKeys[activeIndex];
const activeLink = document.querySelector(`[href="${activeHref}"]`);
if (activeLink) {
activeLink.classList.add('active');
}
}
}
// Advanced Section Transitions
function initSectionTransitions() {
const transitionOverlay = document.querySelector('.transition-overlay');
window.triggerSectionTransition = function(callback) {
// Create ripple effect
transitionOverlay.classList.add('ripple-active');
// Execute callback during transition
setTimeout(() => {
if (callback) callback();
}, 300);
// Remove transition effect
setTimeout(() => {
transitionOverlay.classList.remove('ripple-active');
}, 800);
};
// Mouse-based ripple origin
document.addEventListener('mousemove', (e) => {
const x = (e.clientX / window.innerWidth) * 100;
const y = (e.clientY / window.innerHeight) * 100;
transitionOverlay.style.background = `radial-gradient(circle at ${x}% ${y}%, var(--cosmic-teal) 0%, var(--nebula-purple) 50%, var(--deep-space-blue) 100%)`;
});
}
// Accordion Functionality
function initAccordion() {
const accordionItems = document.querySelectorAll('.accordion-item');
accordionItems.forEach(item => {
const header = item.querySelector('.accordion-header');
const content = item.querySelector('.accordion-content');
header.addEventListener('click', () => {
const isActive = item.classList.contains('active');
// Close all accordions
accordionItems.forEach(otherItem => {
otherItem.classList.remove('active');
const otherContent = otherItem.querySelector('.accordion-content');
otherContent.style.maxHeight = '0';
});
// Toggle current accordion
if (!isActive) {
item.classList.add('active');
content.style.maxHeight = content.scrollHeight + 'px';
// Add ripple effect to header
createRipple(header, event);
}
});
});
// Open first accordion by default
setTimeout(() => {
if (accordionItems.length > 0) {
accordionItems[0].querySelector('.accordion-header').click();
}
}, 500);
}
// Advanced Team Carousel
function initTeamCarousel() {
const teamTrack = document.querySelector('.team-track');
const teamMembers = document.querySelectorAll('.team-member');
const dots = document.querySelectorAll('.dot');
const prevBtn = document.querySelector('.prev-btn');
const nextBtn = document.querySelector('.next-btn');
let currentIndex = 0;
const totalMembers = teamMembers.length;
let autoPlayInterval;
function updateCarousel() {
// Move track
const translateX = -(currentIndex * 332); // 300px width + 32px margin
teamTrack.style.transform = `translateX(${translateX}px)`;
// Update active states
teamMembers.forEach((member, index) => {
member.classList.remove('active');
if (index === currentIndex) {
member.classList.add('active');
}
});
// Update dots
dots.forEach((dot, index) => {
dot.classList.remove('active');
if (index === currentIndex) {
dot.classList.add('active');
}
});
// Add entrance animations
const activeMember = teamMembers[currentIndex];
activeMember.style.animation = 'none';
activeMember.offsetHeight; // Trigger reflow
activeMember.style.animation = 'fadeInScale 0.6s ease forwards';
}
function nextSlide() {
currentIndex = (currentIndex + 1) % totalMembers;
updateCarousel();
}
function prevSlide() {
currentIndex = (currentIndex - 1 + totalMembers) % totalMembers;
updateCarousel();
}
function goToSlide(index) {
currentIndex = index;
updateCarousel();
}
// Event listeners
nextBtn.addEventListener('click', () => {
nextSlide();
resetAutoPlay();
createRipple(nextBtn, event);
});
prevBtn.addEventListener('click', () => {
prevSlide();
resetAutoPlay();
createRipple(prevBtn, event);
});
dots.forEach((dot, index) => {
dot.addEventListener('click', () => {
goToSlide(index);
resetAutoPlay();
createRipple(dot, event);
});
});
// Auto-play functionality
function startAutoPlay() {
autoPlayInterval = setInterval(nextSlide, 4000);
}
function resetAutoPlay() {
clearInterval(autoPlayInterval);
startAutoPlay();
}
// Pause on hover
const teamCarousel = document.querySelector('.team-carousel');
teamCarousel.addEventListener('mouseenter', () => {
clearInterval(autoPlayInterval);
});
teamCarousel.addEventListener('mouseleave', () => {
startAutoPlay();
});
// Initialize
updateCarousel();
startAutoPlay();
// Add CSS animations
const style = document.createElement('style');
style.textContent = `
@keyframes fadeInScale {
0% {
opacity: 0.7;
transform: scale(0.9) translateY(20px);
}
100% {
opacity: 1;
transform: scale(1) translateY(0);
}
}
`;
document.head.appendChild(style);
}
// Advanced Scroll Effects
function initScrollEffects() {
// Parallax for hero elements
const heroContent = document.querySelector('.hero-content');
const stars = document.querySelector('.stars');
const nebula = document.querySelector('.nebula');
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
// Staggered animations for accordion items
if (entry.target.classList.contains('accordion-item')) {
const items = document.querySelectorAll('.accordion-item');
items.forEach((item, index) => {
setTimeout(() => {
item.style.opacity = '1';
item.style.transform = 'translateY(0)';
}, index * 100);
});
}
}
});
}, observerOptions);
// Observe sections for fade-in effects
const sectionsToObserve = document.querySelectorAll('.orrery-section, .about-section, .team-section');
sectionsToObserve.forEach(section => {
section.style.opacity = '0';
section.style.transform = 'translateY(30px)';
section.style.transition = 'opacity 0.8s ease, transform 0.8s ease';
observer.observe(section);
});
// Observe accordion items
const accordionItems = document.querySelectorAll('.accordion-item');
accordionItems.forEach(item => {
item.style.opacity = '0';
item.style.transform = 'translateY(20px)';
item.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(item);
});
// Smooth parallax on scroll
let ticking = false;
window.addEventListener('scroll', () => {
if (!ticking) {
requestAnimationFrame(() => {
const scrolled = window.pageYOffset;
if (scrolled < window.innerHeight && heroContent && stars && nebula) {
const parallaxSpeed = scrolled * 0.5;
const starsSpeed = scrolled * 0.2;
const nebulaSpeed = scrolled * 0.3;
heroContent.style.transform = `translateY(${parallaxSpeed}px)`;
stars.style.transform = `translateY(${starsSpeed}px)`;
nebula.style.transform = `translateY(${nebulaSpeed}px)`;
}
ticking = false;
});
ticking = true;
}
});
}
// Navigation Effects
function initNavigationEffects() {
const navbar = document.querySelector('.navbar');
let lastScrollY = window.scrollY;
window.addEventListener('scroll', () => {
const currentScrollY = window.scrollY;
// Dynamic navbar background
if (currentScrollY > 50) {
navbar.style.background = 'rgba(11, 20, 38, 0.95)';
navbar.style.borderBottom = '1px solid rgba(78, 205, 196, 0.3)';
navbar.style.backdropFilter = 'blur(15px)';
} else {
navbar.style.background = 'rgba(11, 20, 38, 0.9)';
navbar.style.borderBottom = '1px solid rgba(78, 205, 196, 0.1)';
navbar.style.backdropFilter = 'blur(10px)';
}
lastScrollY = currentScrollY;
});
// Logo click handler
const logo = document.querySelector('.nav-logo a');
if (logo) {
logo.addEventListener('click', (e) => {
e.preventDefault();
triggerSectionTransition(() => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
});
}
// CTA button functionality
const ctaButton = document.querySelector('.cta-button');
if (ctaButton) {
ctaButton.addEventListener('click', (e) => {
e.preventDefault();
createRipple(ctaButton, e);
// Navigate to orrery section
triggerSectionTransition(() => {
const orrerySection = document.querySelector('#orrery');
if (orrerySection) {
orrerySection.scrollIntoView({
behavior: 'smooth'
});
}
});
});
}
}
// Dynamic Background Effects
function initDynamicBackgrounds() {
// Enhanced star field
createDynamicStars();
// Shooting stars
createShootingStars();
// Mouse interaction with nebula
initNebulaInteraction();
// Orbital animations enhancement
enhanceOrbitalAnimations();
}
function createDynamicStars() {
const starsContainer = document.querySelector('.stars');
if (!starsContainer) return;
// Create additional dynamic stars
for (let i = 0; i < 50; i++) {
const star = document.createElement('div');
star.className = 'dynamic-star';
star.style.cssText = `
position: absolute;
width: ${Math.random() * 3 + 1}px;
height: ${Math.random() * 3 + 1}px;
background: white;
border-radius: 50%;
left: ${Math.random() * 100}%;
top: ${Math.random() * 100}%;
animation: twinkle ${Math.random() * 3 + 2}s infinite;
animation-delay: ${Math.random() * 2}s;
pointer-events: none;
z-index: 1;
`;
starsContainer.appendChild(star);
}
}
function createShootingStars() {
const sections = document.querySelectorAll('.section');
function createShootingStar() {
sections.forEach(section => {
if (Math.random() < 0.3) { // 30% chance per section
const shootingStar = document.createElement('div');
shootingStar.className = 'shooting-star';
const startX = Math.random() * window.innerWidth;
const startY = Math.random() * (window.innerHeight * 0.6);
shootingStar.style.cssText = `
position: absolute;
left: ${startX}px;
top: ${startY}px;
width: 2px;
height: 2px;
background: white;
border-radius: 50%;
box-shadow: 0 0 10px white, 0 0 20px rgba(78, 205, 196, 0.5);
pointer-events: none;
z-index: 5;
`;
section.appendChild(shootingStar);
// Animate shooting star
const animation = shootingStar.animate([
{
transform: 'translateX(0) translateY(0) scale(1)',
opacity: 0,
boxShadow: '0 0 10px white'
},
{
transform: 'translateX(50px) translateY(25px) scale(1)',
opacity: 1,
boxShadow: '0 0 20px white, 0 0 40px rgba(78, 205, 196, 0.8)'
},
{
transform: 'translateX(300px) translateY(150px) scale(0)',
opacity: 0,
boxShadow: '0 0 5px white'
}
], {
duration: 1500,
easing: 'ease-out'
});
animation.onfinish = () => {
shootingStar.remove();
};
}
});
}
// Create shooting stars periodically
setInterval(createShootingStar, Math.random() * 8000 + 3000);
}
function initNebulaInteraction() {
const sections = document.querySelectorAll('.section');
sections.forEach(section => {
const nebula = section.querySelector('.nebula, .nebula-variant');
if (nebula) {
section.addEventListener('mousemove', (e) => {
const rect = section.getBoundingClientRect();
const x = (e.clientX - rect.left) / rect.width - 0.5;
const y = (e.clientY - rect.top) / rect.height - 0.5;
nebula.style.transform = `translate(${x * 20}px, ${y * 20}px)`;
});
section.addEventListener('mouseleave', () => {
nebula.style.transform = 'translate(0, 0)';
});
}
});
}
function enhanceOrbitalAnimations() {
const featureCards = document.querySelectorAll('.feature-card');
featureCards.forEach(card => {
const orbitSystem = card.querySelector('.orbit-system');
if (orbitSystem) {
card.addEventListener('mouseenter', () => {
const orbits = orbitSystem.querySelectorAll('.orbit');
const planets = orbitSystem.querySelectorAll('.planet');
orbits.forEach((orbit, index) => {
orbit.style.animationDuration = `${1 + index * 0.5}s`;
orbit.style.borderColor = 'rgba(78, 205, 196, 0.6)';
});
planets.forEach(planet => {
planet.style.boxShadow = `0 0 15px ${planet.style.background}`;
});
});
card.addEventListener('mouseleave', () => {
const orbits = orbitSystem.querySelectorAll('.orbit');
const planets = orbitSystem.querySelectorAll('.planet');
orbits.forEach((orbit, index) => {
orbit.style.animationDuration = `${4 + index * 2}s`;
orbit.style.borderColor = 'rgba(78, 205, 196, 0.3)';
});
planets.forEach(planet => {
planet.style.boxShadow = `0 0 10px ${planet.style.background}`;
});
});
}
});
}
// Utility Functions
function createRipple(element, event) {
const ripple = document.createElement('span');
const rect = element.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
const x = event.clientX - rect.left - size / 2;
const y = event.clientY - rect.top - size / 2;
ripple.style.cssText = `
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.3);
transform: scale(0);
animation: ripple-effect 0.6s linear;
left: ${x}px;
top: ${y}px;
width: ${size}px;
height: ${size}px;
pointer-events: none;
`;
element.style.position = 'relative';
element.style.overflow = 'hidden';
element.appendChild(ripple);
// Add ripple animation if not exists
if (!document.querySelector('#ripple-styles')) {
const style = document.createElement('style');
style.id = 'ripple-styles';
style.textContent = `
@keyframes ripple-effect {
to {
transform: scale(2);
opacity: 0;
}
}
`;
document.head.appendChild(style);
}
setTimeout(() => {
ripple.remove();
}, 600);
}
// Performance optimizations
function optimizeAnimations() {
// Use transform3d for hardware acceleration
const animatedElements = document.querySelectorAll('.orbit, .planet, .team-track');
animatedElements.forEach(element => {
element.style.transform += ' translateZ(0)';
});
}
// Initialize performance optimizations
setTimeout(optimizeAnimations, 1000);
// Smooth resize handling
let resizeTimeout;
window.addEventListener('resize', () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
// Recalculate positions and sizes
const teamCarousel = document.querySelector('.team-carousel');
if (teamCarousel) {
// Trigger carousel update
const currentActive = document.querySelector('.team-member.active');
if (currentActive) {
const index = Array.from(document.querySelectorAll('.team-member')).indexOf(currentActive);
const teamTrack = document.querySelector('.team-track');
teamTrack.style.transform = `translateX(${-(index * 332)}px)`;
}
}
}, 250);
});
// Accessibility improvements
document.addEventListener('keydown', (e) => {
if (e.key === 'Tab') {
document.body.classList.add('keyboard-navigation');
}
});
document.addEventListener('mousedown', () => {
document.body.classList.remove('keyboard-navigation');
});
// Add focus styles for keyboard navigation
const focusStyles = document.createElement('style');
focusStyles.textContent = `
.keyboard-navigation *:focus {
outline: 2px solid var(--cosmic-teal) !important;
outline-offset: 2px;
box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.3);
}
`;
document.head.appendChild(focusStyles);