-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
49 lines (46 loc) · 1.85 KB
/
script.js
File metadata and controls
49 lines (46 loc) · 1.85 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
// Animated underline on nav for active section
window.addEventListener('scroll', () => {
const fromTop = window.scrollY + 80; // Header offset
document.querySelectorAll('nav a').forEach(link => {
const section = document.querySelector(link.getAttribute('href'));
if (section && section.offsetTop <= fromTop && section.offsetTop + section.offsetHeight > fromTop) {
link.classList.add('active');
} else {
link.classList.remove('active');
}
});
});
// Contact: Copy email with feedback
function copyEmail() {
const email = document.getElementById('email').textContent.trim();
navigator.clipboard.writeText(email).then(() => {
const btn = document.getElementById('copyBtn');
btn.innerText = 'Copied!';
setTimeout(() => { btn.innerText = 'Copy'; }, 1400);
});
}
// Reveal animation for project cards on scroll
function revealCards() {
const reveals = document.querySelectorAll('.project-card');
for (let i = 0; i < reveals.length; i++) {
const windowHeight = window.innerHeight;
const revealTop = reveals[i].getBoundingClientRect().top;
if (revealTop < windowHeight - 50) {
reveals[i].style.opacity = '1';
reveals[i].style.transform = 'none';
}
}
}
window.addEventListener('scroll', revealCards);
window.addEventListener('load', revealCards);
// Social links sparkle hover effect
document.querySelectorAll('.social-links a').forEach(link => {
link.addEventListener('mouseenter', function() {
this.style.boxShadow = '0 0 28px #f7b800bb';
this.style.transform = 'scale(1.16) rotate(-5deg)';
});
link.addEventListener('mouseleave', function() {
this.style.boxShadow = '0 2px 12px #b3920033';
this.style.transform = '';
});
});