-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (48 loc) · 2 KB
/
index.js
File metadata and controls
59 lines (48 loc) · 2 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
function updateLinkColor() {
const currentlyViewing = window.location.hash;
if (currentlyViewing) {
const currentLink = document.querySelector(`.links-container a[href="${currentlyViewing}"]`);
const otherLinks = document.querySelectorAll(`.links-container a:not(a[href="${currentlyViewing}"])`)
if (currentLink) {
currentLink.classList.add('green-glow');
currentLink.classList.remove('glow');
}
otherLinks.forEach(lnk => {
lnk.classList.remove('green-glow');
lnk.classList.add('glow');
});
}
}
function handleParagraphIntersection(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.animation = 'slide-in-ltr 1s ease-in-out forwards';
observer.unobserve(entry.target);
}
});
}
document.addEventListener('DOMContentLoaded', () => {
// Give all project images hover effects
const images = document.querySelectorAll('.project img');
images.forEach(img => {
img.addEventListener('mousemove', (e) => {
const mouseX = (e.clientX / window.innerWidth - 0.5) * 50;
const mouseY = (e.clientY / window.innerHeight - 0.5) * 50;
const scale = 1.1;
img.style.transform = `translate(${mouseX}px, ${mouseY}px) scale(${scale})`;
});
img.addEventListener('mouseleave', () => {
img.style.transform = 'translate(0, 0)';
});
});
// Make the paragraphs fade in once they're rendered
const paragraphs = document.querySelectorAll('#about-me-section p');
const paragraphsObserver = new IntersectionObserver(handleParagraphIntersection, { threshold: 0.5 });
paragraphs.forEach(paragraph => {
paragraphsObserver.observe(paragraph);
});
// Update the navbar links color based on the window hash
updateLinkColor();
window.addEventListener('hashchange', updateLinkColor);
});