-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
107 lines (89 loc) · 3.34 KB
/
index.js
File metadata and controls
107 lines (89 loc) · 3.34 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
document.addEventListener('DOMContentLoaded', () => {
const progressItems = document.querySelectorAll('.progress-item');
const progressLineFill = document.querySelector('.progress-line-fill');
const progressTrack = document.querySelector('.progress-track');
const sections = [];
progressItems.forEach(item => {
const id = item.dataset.section;
let el;
if (id === 'hero') {
el = document.querySelector('.hero-flow');
} else {
el = document.getElementById(id);
}
if (el) {
sections.push({ id, el });
}
});
const updateProgress = () => {
if (sections.length === 0) return;
const viewportHeight = window.innerHeight;
const activationThreshold = viewportHeight * 0.35;
let activeIdx = 0;
for (let idx = 0; idx < sections.length; idx++) {
const rect = sections[idx].el.getBoundingClientRect();
if (rect.top <= activationThreshold) {
activeIdx = idx;
} else {
break;
}
}
if (progressLineFill && progressTrack) {
const trackHeight = progressTrack.offsetHeight;
const maxFillHeight = trackHeight - 44;
const fillHeight = (activeIdx / Math.max(sections.length - 1, 1)) * maxFillHeight;
progressLineFill.style.height = `${Math.min(Math.max(fillHeight, 0), maxFillHeight)}px`;
}
progressItems.forEach(item => {
const sectionId = item.dataset.section;
const sectionIdx = sections.findIndex(s => s.id === sectionId);
item.classList.remove('active', 'passed');
if (sectionIdx === activeIdx) {
item.classList.add('active');
} else if (sectionIdx >= 0 && sectionIdx < activeIdx) {
item.classList.add('passed');
}
});
};
window.addEventListener('scroll', updateProgress, { passive: true });
updateProgress();
});
document.addEventListener('DOMContentLoaded', () => {
const domainBtns = document.querySelectorAll('.domain-btn');
const domainContents = document.querySelectorAll('.domain-content');
domainBtns.forEach(btn => {
btn.addEventListener('click', () => {
const tab = btn.dataset.tab;
domainBtns.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
domainContents.forEach(content => content.classList.remove('active'));
document.getElementById(`${tab}-content`).classList.add('active');
});
});
const carouselNavs = document.querySelectorAll('.carousel-nav');
carouselNavs.forEach(nav => {
nav.addEventListener('click', () => {
const carouselId = nav.dataset.carousel;
const carousel = document.getElementById(`carousel-${carouselId}`);
const items = carousel.querySelectorAll('.carousel-item');
let currentIndex = Array.from(items).findIndex(item => item.classList.contains('active'));
items[currentIndex].classList.remove('active');
if (nav.classList.contains('prev')) {
currentIndex = (currentIndex - 1 + items.length) % items.length;
} else {
currentIndex = (currentIndex + 1) % items.length;
}
items[currentIndex].classList.add('active');
items.forEach((item, idx) => {
const videos = item.querySelectorAll('video');
videos.forEach(video => {
if (idx === currentIndex) {
video.play();
} else {
video.pause();
}
});
});
});
});
});