-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
482 lines (405 loc) · 14.3 KB
/
script.js
File metadata and controls
482 lines (405 loc) · 14.3 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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
// Modern JavaScript for Enhanced User Experience - Updated for Mikio Harman
// Navigation functionality
document.addEventListener('DOMContentLoaded', function() {
const navToggle = document.getElementById('nav-toggle');
const navMenu = document.getElementById('nav-menu');
const navbar = document.getElementById('navbar');
const navLinks = document.querySelectorAll('.nav-link');
// Mobile menu toggle
navToggle.addEventListener('click', function() {
navMenu.classList.toggle('active');
navToggle.classList.toggle('active');
});
// Close mobile menu when clicking on a link
navLinks.forEach(link => {
link.addEventListener('click', function() {
navMenu.classList.remove('active');
navToggle.classList.remove('active');
});
});
// Navbar scroll effect
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Smooth scrolling for navigation links
navLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
const offsetTop = targetSection.offsetTop - 70; // Account for fixed navbar
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
// Initialize scroll animations
initScrollAnimations();
// Initialize typing effect for hero section
initTypingEffect();
// Initialize project hover effects
initProjectEffects();
// Initialize blog animations
initBlogAnimations();
// Initialize connect animations
initConnectAnimations();
// Initialize statistics counter
initStatsCounter();
});
// Scroll animations
function initScrollAnimations() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, observerOptions);
// Add animation classes and observe elements
const animateElements = document.querySelectorAll('.timeline-item, .project-card, .skill-category, .education-card, .blog-card, .highlight-item');
animateElements.forEach((el, index) => {
// Add staggered animation delay
el.style.transitionDelay = `${index * 0.1}s`;
el.classList.add('fade-in');
observer.observe(el);
});
// Special animations for about section
const aboutText = document.querySelector('.about-text');
const profileCard = document.querySelector('.profile-card');
if (aboutText) {
aboutText.classList.add('slide-in-left');
observer.observe(aboutText);
}
if (profileCard) {
profileCard.classList.add('slide-in-right');
observer.observe(profileCard);
}
}
// Enhanced typing effect for hero section
function initTypingEffect() {
const heroTitle = document.querySelector('.hero-title .gradient-text');
if (!heroTitle) return;
const text = heroTitle.textContent;
heroTitle.textContent = '';
heroTitle.style.borderRight = '2px solid var(--tech-cyan)';
let index = 0;
function typeWriter() {
if (index < text.length) {
heroTitle.textContent += text.charAt(index);
index++;
// Vary typing speed for more natural effect
const delay = Math.random() * 100 + 50;
setTimeout(typeWriter, delay);
} else {
// Remove cursor after typing is complete
setTimeout(() => {
heroTitle.style.borderRight = 'none';
}, 1000);
}
}
// Start typing effect after a delay
setTimeout(typeWriter, 1500);
}
// Enhanced project hover effects
function initProjectEffects() {
const projectCards = document.querySelectorAll('.project-card');
projectCards.forEach(card => {
card.addEventListener('mouseenter', function() {
// Add subtle tilt effect
this.style.transform = 'translateY(-5px) rotateX(2deg) rotateY(2deg)';
this.style.transition = 'all 0.3s ease';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) rotateX(0) rotateY(0)';
});
// Add click ripple effect
card.addEventListener('click', function(e) {
const ripple = document.createElement('span');
const rect = this.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
const x = e.clientX - rect.left - size / 2;
const y = e.clientY - rect.top - size / 2;
ripple.style.cssText = `
position: absolute;
border-radius: 50%;
background: rgba(0, 188, 212, 0.3);
transform: scale(0);
animation: ripple 0.6s linear;
width: ${size}px;
height: ${size}px;
left: ${x}px;
top: ${y}px;
pointer-events: none;
`;
this.style.position = 'relative';
this.style.overflow = 'hidden';
this.appendChild(ripple);
setTimeout(() => {
ripple.remove();
}, 600);
});
});
}
// Blog section animations
function initBlogAnimations() {
const blogCards = document.querySelectorAll('.blog-card');
blogCards.forEach(card => {
card.addEventListener('mouseenter', function() {
const blogLink = this.querySelector('.blog-link');
if (blogLink) {
blogLink.style.transform = 'translateX(5px)';
}
});
card.addEventListener('mouseleave', function() {
const blogLink = this.querySelector('.blog-link');
if (blogLink) {
blogLink.style.transform = 'translateX(0)';
}
});
});
// Featured blog card special effect
const featuredCard = document.querySelector('.blog-card.featured');
if (featuredCard) {
setInterval(() => {
featuredCard.style.borderColor = 'var(--tech-electric)';
setTimeout(() => {
featuredCard.style.borderColor = 'var(--tech-cyan)';
}, 1000);
}, 5000);
}
}
// Connect section animations
function initConnectAnimations() {
const networkNodes = document.querySelectorAll('.network-node');
// Add hover effects to network nodes
networkNodes.forEach(node => {
node.addEventListener('mouseenter', function() {
this.style.transform += ' scale(1.1)';
this.style.background = 'var(--tech-electric)';
});
node.addEventListener('mouseleave', function() {
this.style.transform = this.style.transform.replace(' scale(1.1)', '');
if (!this.classList.contains('main-node')) {
this.style.background = 'var(--tech-cyan)';
} else {
this.style.background = 'var(--primary-forest)';
}
});
});
// LinkedIn CTA pulse effect
const linkedinCTAs = document.querySelectorAll('.linkedin-main-cta, .linkedin-cta');
linkedinCTAs.forEach(cta => {
setInterval(() => {
cta.style.boxShadow = '0 0 25px rgba(0, 188, 212, 0.6)';
setTimeout(() => {
cta.style.boxShadow = '';
}, 1500);
}, 8000);
});
// Highlight items hover effect
const highlightItems = document.querySelectorAll('.highlight-item');
highlightItems.forEach(item => {
item.addEventListener('mouseenter', function() {
this.style.transform = 'translateX(5px)';
this.style.borderLeftWidth = '5px';
});
item.addEventListener('mouseleave', function() {
this.style.transform = 'translateX(0)';
this.style.borderLeftWidth = '3px';
});
});
}
// Statistics counter animation
function initStatsCounter() {
const stats = document.querySelectorAll('.stat-number');
const observerOptions = {
threshold: 0.5
};
const statsObserver = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
const target = entry.target;
const text = target.textContent;
if (text.includes('+') && !text.includes('Billions')) {
const num = parseFloat(text.replace('+', ''));
animateCounter(target, 0, num, 2000);
} else if (text === 'Billions') {
// Special animation for billions
target.style.animation = 'pulse 2s ease-in-out';
}
statsObserver.unobserve(target);
}
});
}, observerOptions);
stats.forEach(stat => {
statsObserver.observe(stat);
});
}
// Counter animation function
function animateCounter(element, start, end, duration) {
const startTime = performance.now();
const originalText = element.textContent;
const hasDecimal = originalText.includes('.');
function updateCounter(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
let current = start + (end - start) * progress;
if (hasDecimal) {
current = current.toFixed(1);
} else {
current = Math.floor(current);
}
element.textContent = current + (originalText.includes('+') ? '+' : '');
if (progress < 1) {
requestAnimationFrame(updateCounter);
}
}
requestAnimationFrame(updateCounter);
}
// Scroll to top functionality
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
// Add scroll to top button
document.addEventListener('DOMContentLoaded', function() {
const scrollButton = document.createElement('button');
scrollButton.innerHTML = '<i class="fas fa-arrow-up"></i>';
scrollButton.className = 'scroll-to-top';
scrollButton.style.cssText = `
position: fixed;
bottom: 2rem;
right: 2rem;
width: 50px;
height: 50px;
background: var(--tech-cyan);
color: var(--snow-white);
border: none;
border-radius: 50%;
cursor: pointer;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
z-index: 1000;
box-shadow: var(--shadow-lg);
`;
document.body.appendChild(scrollButton);
scrollButton.addEventListener('click', scrollToTop);
// Show/hide scroll button based on scroll position
window.addEventListener('scroll', function() {
if (window.scrollY > 300) {
scrollButton.style.opacity = '1';
scrollButton.style.visibility = 'visible';
} else {
scrollButton.style.opacity = '0';
scrollButton.style.visibility = 'hidden';
}
});
});
// Enhanced link tracking for analytics
function trackLinkClick(linkType, destination) {
// This function can be used to track user interactions
console.log(`User clicked ${linkType} link to ${destination}`);
// If you want to add analytics later, you can implement it here
// Example: gtag('event', 'click', { 'event_category': linkType, 'event_label': destination });
}
// Add click tracking to external links
document.addEventListener('DOMContentLoaded', function() {
const socialLinks = document.querySelectorAll('a[href*="linkedin.com"], a[href*="github.com"], a[href*="medium.com"]');
socialLinks.forEach(link => {
link.addEventListener('click', function() {
const url = this.href;
let platform = '';
if (url.includes('linkedin.com')) platform = 'LinkedIn';
else if (url.includes('github.com')) platform = 'GitHub';
else if (url.includes('medium.com')) platform = 'Medium';
trackLinkClick('social', platform);
});
});
// Track blog link clicks
const blogLinks = document.querySelectorAll('.blog-link');
blogLinks.forEach(link => {
link.addEventListener('click', function() {
trackLinkClick('blog', 'Medium');
});
});
});
// Add CSS animations
const style = document.createElement('style');
style.textContent = `
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes ripple {
to {
transform: scale(4);
opacity: 0;
}
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
}
@keyframes glow {
0%, 100% {
box-shadow: 0 0 20px rgba(0, 188, 212, 0.5);
}
50% {
box-shadow: 0 0 30px rgba(0, 188, 212, 0.8);
}
}
.scroll-to-top:hover {
background: var(--tech-electric) !important;
transform: translateY(-2px);
}
.linkedin-main-cta:hover,
.linkedin-cta:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0, 188, 212, 0.3);
}
.education-card:hover .education-icon {
animation: pulse 0.6s ease;
}
.timeline-item:hover .timeline-dot {
transform: scale(1.2);
background: var(--tech-electric);
}
.blog-card.featured {
animation: glow 4s ease-in-out infinite;
}
.highlight-item {
transition: all 0.3s ease;
}
.connect-cta .btn:hover {
transform: translateY(-2px);
}
`;
document.head.appendChild(style);
// Performance optimization: Debounce scroll events
function debounce(func, wait) {
let timeout;
return function execute