-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
190 lines (162 loc) · 5.97 KB
/
script.js
File metadata and controls
190 lines (162 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
document.addEventListener('DOMContentLoaded', () => {
// Simple intersection-based reveal animations
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('in');
observer.unobserve(entry.target);
}
});
}, { threshold: 0.15 });
document.querySelectorAll('[data-animate]').forEach((el) => observer.observe(el));
// Animate divider lines on scroll
const lineObserver = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const divider = entry.target;
setTimeout(() => {
divider.classList.add('animate');
}, 100);
lineObserver.unobserve(entry.target);
}
});
}, { threshold: 0.2 });
// Observe services header divider
const servicesDivider = document.querySelector('.services-divider');
if (servicesDivider) {
lineObserver.observe(servicesDivider);
}
// Observe all service dividers
document.querySelectorAll('.service-divider').forEach((divider) => {
lineObserver.observe(divider);
});
// Observe all process dividers
document.querySelectorAll('.process-divider').forEach((divider) => {
lineObserver.observe(divider);
});
// Observe about section divider
const aboutDivider = document.querySelector('.about-divider');
if (aboutDivider) {
lineObserver.observe(aboutDivider);
}
// Observe work together section divider
const workTogetherDivider = document.querySelector('.work-together-divider');
if (workTogetherDivider) {
lineObserver.observe(workTogetherDivider);
}
// Observe all info dividers
document.querySelectorAll('.info-divider').forEach((divider) => {
lineObserver.observe(divider);
});
// Observe testimonials dividers
document.querySelectorAll('.testimonials-divider').forEach((divider) => {
lineObserver.observe(divider);
});
// Observe featured work divider
const featuredWorkDivider = document.querySelector('.featured-work-divider');
if (featuredWorkDivider) {
lineObserver.observe(featuredWorkDivider);
}
// Observe featured work bottom divider
const featuredWorkDividerBottom = document.querySelector('.featured-work-divider-bottom');
if (featuredWorkDividerBottom) {
lineObserver.observe(featuredWorkDividerBottom);
}
// Animate featured work cards on scroll
const cardObserver = new IntersectionObserver((entries) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
setTimeout(() => {
entry.target.classList.add('animate');
}, index * 150); // Stagger animation for each card
cardObserver.unobserve(entry.target);
}
});
}, { threshold: 0.15 });
// Observe all featured work cards
document.querySelectorAll('.featured-work-card').forEach((card) => {
cardObserver.observe(card);
});
// Testimonial slider functionality
const testimonials = [
{
company: 'Conduit Commerce',
quote: '"Collaborating with Gaurav has been a great experience. He has a strong grasp of backend systems and always ensures clean, efficient, and maintainable code."',
name: 'Shrikant Patil',
title: 'Developer',
avatar: 'assets/img/Shrikant.jpeg'
},
{
company: 'Conduit Commerce',
quote: '"Gaurav is a great developer. He is always willing to help and is a quick learner. He is a great team player and is always willing to go the extra mile."',
name: 'Vishal Gadiya',
title: 'Developer',
avatar: 'assets/img/Vishal.jpeg'
}
];
let currentTestimonialIndex = 0;
const testimonialCompanyEl = document.getElementById('testimonial-company');
const testimonialTextEl = document.getElementById('testimonial-text');
const testimonialNameEl = document.getElementById('testimonial-name');
const testimonialTitleEl = document.getElementById('testimonial-title');
const testimonialAvatarEl = document.getElementById('testimonial-avatar');
const prevBtn = document.querySelector('.testimonial-prev');
const nextBtn = document.querySelector('.testimonial-next');
const dots = document.querySelectorAll('.testimonial-dots .dot');
function updateTestimonial(index) {
const testimonial = testimonials[index];
const elements = [testimonialCompanyEl, testimonialTextEl, testimonialNameEl, testimonialTitleEl, testimonialAvatarEl];
// Fade out
elements.forEach(el => {
if (el) el.style.opacity = '0';
});
// Update content after brief delay
setTimeout(() => {
if (testimonialCompanyEl) {
testimonialCompanyEl.textContent = testimonial.company || '';
}
if (testimonialTextEl) {
testimonialTextEl.textContent = testimonial.quote;
}
if (testimonialNameEl) {
testimonialNameEl.textContent = testimonial.name;
}
if (testimonialTitleEl) {
testimonialTitleEl.textContent = testimonial.title;
}
if (testimonialAvatarEl) {
testimonialAvatarEl.src = testimonial.avatar;
testimonialAvatarEl.alt = testimonial.name;
}
// Fade in
elements.forEach(el => {
if (el) el.style.opacity = '1';
});
// Update dots
dots.forEach((dot, i) => {
if (i === index) {
dot.classList.add('active');
} else {
dot.classList.remove('active');
}
});
currentTestimonialIndex = index;
}, 150);
}
if (prevBtn && nextBtn) {
prevBtn.addEventListener('click', () => {
currentTestimonialIndex = (currentTestimonialIndex - 1 + testimonials.length) % testimonials.length;
updateTestimonial(currentTestimonialIndex);
});
nextBtn.addEventListener('click', () => {
currentTestimonialIndex = (currentTestimonialIndex + 1) % testimonials.length;
updateTestimonial(currentTestimonialIndex);
});
}
// Handle dot clicks
dots.forEach((dot, index) => {
dot.addEventListener('click', () => {
updateTestimonial(index);
});
});
});