-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
129 lines (113 loc) · 3.73 KB
/
script.js
File metadata and controls
129 lines (113 loc) · 3.73 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
// Modern JavaScript for enhanced interactivity
document.addEventListener('DOMContentLoaded', function() {
initializeInteractions();
initializeScrollAnimations();
initializeNavigation();
});
// Initialize navigation highlighting
function initializeNavigation() {
const navLinks = document.querySelectorAll('nav a');
const currentPath = window.location.pathname.split('/').pop() || 'index.html';
navLinks.forEach(link => {
const href = link.getAttribute('href');
if (href === currentPath || (currentPath === '' && href === 'index.html')) {
link.style.color = '#f093fb';
}
});
}
// Enhanced scroll animations
function initializeScrollAnimations() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.animation = 'slideInUp 0.8s ease forwards';
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe project cards and list items
document.querySelectorAll('.project-card, .content-section li').forEach(el => {
el.style.opacity = '0';
observer.observe(el);
});
}
// Enhanced interaction handlers
function initializeInteractions() {
// Add smooth click feedback to buttons
const buttons = document.querySelectorAll('.cta-button, .project-card, .content-section a');
buttons.forEach(button => {
button.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;
width: ${size}px;
height: ${size}px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.6);
left: ${x}px;
top: ${y}px;
pointer-events: none;
animation: ripple 0.6s ease-out;
`;
this.style.position = 'relative';
this.style.overflow = 'hidden';
this.appendChild(ripple);
setTimeout(() => ripple.remove(), 600);
});
});
}
// Add ripple animation to stylesheet
const style = document.createElement('style');
style.textContent = `
@keyframes ripple {
to {
transform: scale(4);
opacity: 0;
}
}
`;
document.head.appendChild(style);
// Smooth scroll for internal links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
const href = this.getAttribute('href');
if (href !== '#' && document.querySelector(href)) {
e.preventDefault();
document.querySelector(href).scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Add cursor glow effect on mouse move (optional enhancement)
if (window.innerWidth > 768) {
document.addEventListener('mousemove', function(e) {
const cursor = document.querySelector('body');
cursor.style.setProperty('--cursor-x', e.clientX + 'px');
cursor.style.setProperty('--cursor-y', e.clientY + 'px');
});
}
// Lazy load images (future enhancement)
if ('IntersectionObserver' in window) {
const imageObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src || img.src;
imageObserver.unobserve(img);
}
});
});
document.querySelectorAll('img[data-src]').forEach(img => {
imageObserver.observe(img);
});
}