-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
400 lines (343 loc) Β· 11.9 KB
/
script.js
File metadata and controls
400 lines (343 loc) Β· 11.9 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
// Mobile Navigation Toggle
const navToggle = document.querySelector('.nav-toggle');
const navMenu = document.querySelector('.nav-menu');
const navLinks = document.querySelectorAll('.nav-link');
// Toggle mobile menu
navToggle.addEventListener('click', () => {
navMenu.classList.toggle('active');
// Animate hamburger menu
const bars = navToggle.querySelectorAll('.bar');
bars.forEach((bar, index) => {
if (navMenu.classList.contains('active')) {
if (index === 0) {
bar.style.transform = 'rotate(-45deg) translate(-5px, 6px)';
} else if (index === 1) {
bar.style.opacity = '0';
} else {
bar.style.transform = 'rotate(45deg) translate(-5px, -6px)';
}
} else {
bar.style.transform = 'none';
bar.style.opacity = '1';
}
});
});
// Close mobile menu when clicking on a nav link
navLinks.forEach(link => {
link.addEventListener('click', () => {
navMenu.classList.remove('active');
const bars = navToggle.querySelectorAll('.bar');
bars.forEach(bar => {
bar.style.transform = 'none';
bar.style.opacity = '1';
});
});
});
// Smooth scrolling for navigation links
navLinks.forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const targetId = link.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
const headerOffset = 80; // Height of fixed navbar
const elementPosition = targetSection.offsetTop;
const offsetPosition = elementPosition - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
}
});
});
// Navbar background change on scroll
const navbar = document.querySelector('.navbar');
let lastScrollTop = 0;
window.addEventListener('scroll', () => {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
// Add/remove background class based on scroll position
if (scrollTop > 100) {
navbar.style.background = 'rgba(255, 255, 255, 0.98)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.background = 'rgba(255, 255, 255, 0.95)';
navbar.style.boxShadow = 'none';
}
// Hide/show navbar on scroll
if (scrollTop > lastScrollTop && scrollTop > 300) {
navbar.style.transform = 'translateY(-100%)';
} else {
navbar.style.transform = 'translateY(0)';
}
lastScrollTop = scrollTop;
});
// Animate elements on scroll
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-in');
// Special animation for timeline items
if (entry.target.classList.contains('timeline-item')) {
const delay = Array.from(entry.target.parentNode.children).indexOf(entry.target) * 200;
entry.target.style.animationDelay = `${delay}ms`;
}
// Special animation for project cards
if (entry.target.classList.contains('project-card')) {
const delay = Array.from(entry.target.parentNode.children).indexOf(entry.target) * 300;
entry.target.style.animationDelay = `${delay}ms`;
}
}
});
}, observerOptions);
// Observe all sections and cards
const animateElements = document.querySelectorAll(
'section, .timeline-item, .project-card, .skills-category, .education-card, .contact-item'
);
animateElements.forEach(element => {
observer.observe(element);
});
// Add CSS for scroll animations
const style = document.createElement('style');
style.textContent = `
.timeline-item,
.project-card,
.skills-category,
.education-card,
.contact-item {
opacity: 0;
transform: translateY(30px);
transition: all 0.6s ease-out;
}
.animate-in {
opacity: 1 !important;
transform: translateY(0) !important;
}
.timeline-item:nth-child(even) {
transform: translateX(-30px) translateY(30px);
}
.timeline-item:nth-child(odd) {
transform: translateX(30px) translateY(30px);
}
.timeline-item.animate-in {
transform: translateX(0) translateY(0) !important;
}
`;
document.head.appendChild(style);
// Typing effect for hero title
const heroTitle = document.querySelector('#hero-title');
if (heroTitle) {
const originalText = 'Hi, I\'m ';
const highlightText = 'Bhoomika B';
heroTitle.innerHTML = '';
let i = 0;
const typeWriter = () => {
if (i < originalText.length) {
heroTitle.innerHTML = originalText.substring(0, i + 1);
i++;
setTimeout(typeWriter, 100);
} else if (i < originalText.length + highlightText.length) {
const highlightIndex = i - originalText.length;
heroTitle.innerHTML = originalText + '<span class="highlight">' + highlightText.substring(0, highlightIndex + 1) + '</span>';
i++;
setTimeout(typeWriter, 100);
}
};
// Start typing effect after page load
setTimeout(typeWriter, 1000);
}
// Skill items hover effect with counter animation
const skillItems = document.querySelectorAll('.skill-item');
skillItems.forEach(item => {
item.addEventListener('mouseenter', () => {
item.style.transform = 'translateY(-5px) scale(1.05)';
});
item.addEventListener('mouseleave', () => {
item.style.transform = 'translateY(0) scale(1)';
});
});
// Add click effect to buttons
const buttons = document.querySelectorAll('.btn');
buttons.forEach(button => {
button.addEventListener('click', (e) => {
const ripple = document.createElement('span');
const rect = button.getBoundingClientRect();
const size = Math.max(rect.height, rect.width);
const x = e.clientX - rect.left - size / 2;
const y = e.clientY - rect.top - size / 2;
ripple.style.width = ripple.style.height = size + 'px';
ripple.style.left = x + 'px';
ripple.style.top = y + 'px';
ripple.classList.add('ripple');
button.appendChild(ripple);
setTimeout(() => {
ripple.remove();
}, 600);
});
});
// Add ripple effect CSS
const rippleStyle = document.createElement('style');
rippleStyle.textContent = `
.btn {
position: relative;
overflow: hidden;
}
.ripple {
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.6);
animation: ripple-animation 0.6s linear;
pointer-events: none;
}
@keyframes ripple-animation {
to {
transform: scale(4);
opacity: 0;
}
}
`;
document.head.appendChild(rippleStyle);
// Add parallax effect to hero section
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const hero = document.querySelector('.hero');
if (hero) {
const rate = scrolled * -0.5;
hero.style.transform = `translateY(${rate}px)`;
}
});
// Add active navigation link highlighting
const sections = document.querySelectorAll('section');
const navLinksArray = Array.from(navLinks);
window.addEventListener('scroll', () => {
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (scrollY >= (sectionTop - 200)) {
current = section.getAttribute('id');
}
});
navLinksArray.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${current}`) {
link.classList.add('active');
}
});
});
// Add active link styling
const activeLinkStyle = document.createElement('style');
activeLinkStyle.textContent = `
.nav-link.active {
color: #3498db !important;
position: relative;
}
.nav-link.active::after {
content: '';
position: absolute;
bottom: -5px;
left: 0;
width: 100%;
height: 2px;
background: #3498db;
}
`;
document.head.appendChild(activeLinkStyle);
// Contact form functionality (if you want to add a contact form later)
const contactForm = document.querySelector('#contact-form');
if (contactForm) {
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
// Get form data
const formData = new FormData(contactForm);
const name = formData.get('name');
const email = formData.get('email');
const message = formData.get('message');
// Simple validation
if (!name || !email || !message) {
showNotification('Please fill in all fields', 'error');
return;
}
// Show success message
showNotification('Message sent successfully!', 'success');
contactForm.reset();
});
}
// Notification system
function showNotification(message, type = 'info') {
const notification = document.createElement('div');
notification.className = `notification notification-${type}`;
notification.textContent = message;
// Add notification styles
notification.style.cssText = `
position: fixed;
top: 100px;
right: 20px;
padding: 1rem 1.5rem;
border-radius: 5px;
color: white;
font-weight: 600;
z-index: 1001;
transform: translateX(100%);
transition: transform 0.3s ease;
max-width: 300px;
`;
// Set background based on type
switch (type) {
case 'success':
notification.style.background = '#27ae60';
break;
case 'error':
notification.style.background = '#e74c3c';
break;
default:
notification.style.background = '#3498db';
}
document.body.appendChild(notification);
// Animate in
setTimeout(() => {
notification.style.transform = 'translateX(0)';
}, 100);
// Remove after 3 seconds
setTimeout(() => {
notification.style.transform = 'translateX(100%)';
setTimeout(() => {
notification.remove();
}, 300);
}, 3000);
}
// Add smooth reveal animation for page load
window.addEventListener('load', () => {
document.body.style.opacity = '0';
document.body.style.transition = 'opacity 0.5s ease-in-out';
setTimeout(() => {
document.body.style.opacity = '1';
}, 100);
});
// Performance optimization: Throttle scroll events
function throttle(func, limit) {
let inThrottle;
return function() {
const args = arguments;
const context = this;
if (!inThrottle) {
func.apply(context, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
}
}
// Apply throttling to scroll events
const throttledScrollHandler = throttle(() => {
// Existing scroll logic here
}, 16); // ~60fps
// Console welcome message
console.log(`
π Welcome to Bhoomika's Portfolio!
π©βπ» Built with HTML, CSS, and JavaScript
π§ Contact: bhoomikababu03@gmail.com
π GitHub: github.com/bhoomika0620
`);