-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
322 lines (282 loc) · 9.32 KB
/
script.js
File metadata and controls
322 lines (282 loc) · 9.32 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
window.addEventListener("load", () => {
const preloader = document.getElementById("preloader");
preloader.style.opacity = "0";
preloader.style.pointerEvents = "none";
setTimeout(() => preloader.remove(), 800);
});
// Theme Toggle
function toggleTheme() {
const body = document.body;
const themeIcon = document.querySelector(".theme-icon");
if (body.getAttribute("data-theme") === "light") {
body.removeAttribute("data-theme");
themeIcon.textContent = "🌙";
} else {
body.setAttribute("data-theme", "light");
themeIcon.textContent = "☀️";
}
}
// Contact Details Toggle
function toggleContactDetails() {
const details = document.getElementById("contactDetails");
const btnText = document.getElementById("contactBtnText");
if (details.classList.contains("show")) {
details.classList.remove("show");
btnText.textContent = "Show Contact Details";
} else {
details.classList.add("show");
btnText.textContent = "Hide Contact Details";
// Trigger contact item animations
document.querySelectorAll(".contact-item").forEach((item, index) => {
setTimeout(() => {
item.classList.add("animate");
}, index * 150);
});
}
}
// Role Typing Effect for Home Section
const roleTypingText = document.getElementById("roleTypingText");
const roles = [
"Full Stack Developer",
"Python Developer",
"UI/UX Enthusiast",
"Web Developer",
];
let roleIndex = 0;
let charIndex = 0;
let isDeleting = false;
function typeRole() {
const currentRole = roles[roleIndex];
if (isDeleting) {
roleTypingText.innerHTML =
currentRole.substring(0, charIndex) + '<span class="cursor"></span>';
charIndex--;
if (charIndex < 0) {
isDeleting = false;
roleIndex = (roleIndex + 1) % roles.length;
setTimeout(typeRole, 200);
} else {
setTimeout(typeRole, 50);
}
} else {
roleTypingText.innerHTML =
currentRole.substring(0, charIndex + 1) + '<span class="cursor"></span>';
charIndex++;
if (charIndex === currentRole.length) {
isDeleting = true;
setTimeout(typeRole, 1500);
} else {
setTimeout(typeRole, 100);
}
}
}
// Typing Effect for About Section
const typingText = document.getElementById("typingText");
const text =
"I'm Vishwa Govula, a passionate Full Stack Developer and UI/UX enthusiast dedicated to creating innovative digital experiences. With a strong foundation in modern web technologies, I specialize in building responsive, user-friendly applications that solve real-world problems. My journey in tech is driven by curiosity, creativity, and a commitment to continuous learning. I enjoy transforming ideas into functional, beautiful web solutions and am always excited to take on new challenges that push the boundaries of what's possible.";
let index = 0;
function typeText() {
if (index < text.length) {
typingText.innerHTML =
text.substring(0, index + 1) + '<span class="cursor"></span>';
index++;
setTimeout(typeText, 40);
} else {
typingText.innerHTML = text + '<span class="cursor"></span>';
}
}
// Carousel Functionality
const carouselInner = document.querySelector(".carousel-inner");
const slides = document.querySelectorAll(".project-slide");
const prevBtn = document.querySelector(".carousel-btn.prev");
const nextBtn = document.querySelector(".carousel-btn.next");
const dots = document.querySelectorAll(".carousel-dot");
let currentIndex = 0;
let autoSlideInterval;
function updateCarousel() {
carouselInner.style.transform = `translateX(-${currentIndex * 100}%)`;
slides.forEach((slide, index) => {
slide.classList.toggle("active", index === currentIndex);
});
dots.forEach((dot, index) => {
dot.classList.toggle("active", index === currentIndex);
});
}
function nextSlide() {
currentIndex = (currentIndex + 1) % slides.length;
updateCarousel();
}
function prevSlide() {
currentIndex = (currentIndex - 1 + slides.length) % slides.length;
updateCarousel();
}
function goToSlide(index) {
currentIndex = index;
updateCarousel();
}
function startAutoSlide() {
autoSlideInterval = setInterval(nextSlide, 5000);
}
function stopAutoSlide() {
clearInterval(autoSlideInterval);
}
nextBtn.addEventListener("click", () => {
stopAutoSlide();
nextSlide();
startAutoSlide();
});
prevBtn.addEventListener("click", () => {
stopAutoSlide();
prevSlide();
startAutoSlide();
});
dots.forEach((dot, index) => {
dot.addEventListener("click", () => {
stopAutoSlide();
goToSlide(index);
startAutoSlide();
});
});
// Enhanced scroll animations
function animateOnScroll() {
const sections = document.querySelectorAll("section");
const skillCategories = document.querySelectorAll(".skill-category");
const carousel = document.querySelector(".carousel");
const contactForm = document.querySelector(".contact-form");
const contactInfo = document.querySelector(".contact-info-section");
const formGroups = document.querySelectorAll(".form-group");
const scrollTop = window.pageYOffset;
// Section animations
sections.forEach((section) => {
const offsetTop = section.offsetTop;
const height = section.offsetHeight;
if (scrollTop >= offsetTop - window.innerHeight + 150) {
section.classList.add("visible");
}
});
// Skills animation with stagger
skillCategories.forEach((category, index) => {
const offsetTop = category.offsetTop;
if (scrollTop >= offsetTop - window.innerHeight + 200) {
setTimeout(() => {
category.classList.add("animate");
}, index * 250);
}
});
// Carousel animation
if (carousel && scrollTop >= carousel.offsetTop - window.innerHeight + 200) {
carousel.style.opacity = "1";
carousel.style.transform = "translateY(0)";
}
// Contact section animations
if (
contactForm &&
scrollTop >= contactForm.offsetTop - window.innerHeight + 200
) {
contactForm.classList.add("animate");
formGroups.forEach((group, index) => {
setTimeout(() => {
group.classList.add("animate");
}, index * 150);
});
}
if (
contactInfo &&
scrollTop >= contactInfo.offsetTop - window.innerHeight + 200
) {
setTimeout(() => {
contactInfo.classList.add("animate");
}, 250);
}
}
// Navigation highlighting
function updateNavigation() {
const sections = document.querySelectorAll("section");
const navLinks = document.querySelectorAll(".nav-links a");
const scrollTop = window.pageYOffset + 100;
sections.forEach((section, index) => {
const offsetTop = section.offsetTop;
const height = section.offsetHeight;
if (scrollTop >= offsetTop && scrollTop < offsetTop + height) {
navLinks.forEach((link) => link.classList.remove("active"));
if (navLinks[index]) navLinks[index].classList.add("active");
}
});
}
// Scroll progress indicator
function updateScrollIndicator() {
const scrollTop = window.pageYOffset;
const docHeight = document.body.scrollHeight - window.innerHeight;
const scrollPercent = (scrollTop / docHeight) * 100;
document.querySelector(".scroll-indicator").style.width = scrollPercent + "%";
}
// Smooth scrolling for navigation links
document.querySelectorAll(".nav-links a").forEach((link) => {
link.addEventListener("click", (e) => {
e.preventDefault();
const targetId = link.getAttribute("href");
const targetSection = document.querySelector(targetId);
targetSection.scrollIntoView({ behavior: "smooth" });
});
});
// Enhanced form submission with animation
document.querySelector(".contact-form").addEventListener("submit", (e) => {
e.preventDefault();
const submitBtn = document.querySelector(".submit-btn");
const originalText = submitBtn.textContent;
submitBtn.textContent = "Sending...";
submitBtn.style.background = "var(--hover-color)";
setTimeout(() => {
submitBtn.textContent = "Message Sent!";
submitBtn.style.transform = "scale(1.05)";
setTimeout(() => {
submitBtn.textContent = originalText;
submitBtn.style.background = "var(--accent-color)";
submitBtn.style.transform = "scale(1)";
e.target.reset();
}, 2000);
}, 1000);
});
// Initialize
window.addEventListener("load", () => {
animateOnScroll();
updateNavigation();
updateScrollIndicator();
startAutoSlide();
// Start role typing effect when home section becomes visible
const homeSection = document.getElementById("home");
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
setTimeout(typeRole, 500);
observer.unobserve(homeSection);
}
});
});
observer.observe(homeSection);
// Start typing effect when about section becomes visible
const aboutSection = document.getElementById("about");
const observerAbout = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
setTimeout(typeText, 500);
observerAbout.unobserve(aboutSection);
}
});
});
observerAbout.observe(aboutSection);
});
window.addEventListener("scroll", () => {
animateOnScroll();
updateNavigation();
updateScrollIndicator();
});
// Enhanced parallax effect with subtle movement
window.addEventListener("scroll", () => {
const scrolled = window.pageYOffset;
const parallax = document.querySelector("#home");
const speed = scrolled * 0.3;
if (parallax) {
parallax.style.transform = `translateY(${speed}px)`;
}
});