-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
116 lines (97 loc) · 3.28 KB
/
Copy pathscript.js
File metadata and controls
116 lines (97 loc) · 3.28 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
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const nav = document.querySelector('nav');
const navMenu = document.querySelector('nav ul');
const navLinks = document.querySelectorAll('nav ul li a');
// Toggle menu open/close
mobileMenuBtn.addEventListener('click', () => {
nav.classList.toggle('active');
navMenu.classList.toggle('show');
});
// Close menu after clicking any nav link
navLinks.forEach(link => {
link.addEventListener('click', () => {
nav.classList.remove('active');
navMenu.classList.remove('show');
});
});
// Other functionalities
const tabButtons = document.querySelectorAll('.tab-button');
const tabContents = document.querySelectorAll('.tab-content');
tabButtons.forEach(button => {
button.addEventListener('click', () => {
tabButtons.forEach(btn => btn.classList.remove('active'));
tabContents.forEach(content => content.classList.remove('active'));
button.classList.add('active');
const tabId = button.getAttribute('data-tab') + '-tab';
document.getElementById(tabId).classList.add('active');
});
});
const sliderDots = document.querySelectorAll('.slider-dot');
const sliderTrack = document.querySelector('.testimonial-track');
const slides = document.querySelectorAll('.testimonial-slide');
const sliderArrows = document.querySelectorAll('.slider-arrow');
let currentSlide = 0;
function updateSlider() {
slides.forEach((slide, index) => {
slide.classList.toggle('active', index === currentSlide);
});
sliderDots.forEach((dot, index) => {
dot.classList.toggle('active', index === currentSlide);
});
}
sliderDots.forEach((dot, index) => {
dot.addEventListener('click', () => {
currentSlide = index;
updateSlider();
});
});
sliderArrows.forEach(arrow => {
arrow.addEventListener('click', () => {
if (arrow.classList.contains('prev')) {
currentSlide = (currentSlide - 1 + slides.length) % slides.length;
} else {
currentSlide = (currentSlide + 1) % slides.length;
}
updateSlider();
});
});
// Initialize
updateSlider();
// Typing Animation
function typeWriter(element, text, speed = 50, callback = null) {
let i = 0;
element.textContent = '';
function type() {
if (i < text.length) {
element.textContent += text.charAt(i);
i++;
setTimeout(type, speed);
} else if (callback) {
callback();
}
}
type();
}
document.querySelectorAll('.quote-text').forEach(quote => {
const originalText = quote.textContent;
quote.textContent = '';
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
typeWriter(quote, originalText, 30);
observer.unobserve(quote);
}
});
});
observer.observe(quote);
});
// Progress Bar
function updateProgressBar() {
const scrollTop = window.scrollY;
const docHeight = document.body.offsetHeight - window.innerHeight;
const scrollPercent = (scrollTop / docHeight) * 100;
document.querySelector('.journey-progress-bar').style.width = scrollPercent + '%';
}
window.addEventListener('scroll', updateProgressBar);
window.addEventListener('resize', updateProgressBar);
updateProgressBar();