-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (54 loc) · 1.8 KB
/
Copy pathscript.js
File metadata and controls
63 lines (54 loc) · 1.8 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
const toggle = document.getElementById('nav-toggle');
const mobile = document.getElementById('nav-mobile');
toggle.addEventListener('click', () => {
mobile.classList.toggle('open');
});
mobile.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => mobile.classList.remove('open'));
});
const observer = new IntersectionObserver(
entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
},
{ threshold: 0.1, rootMargin: '0px 0px -40px 0px' }
);
document.querySelectorAll(
'.project-card, .timeline-item, .skill-group, .contact-card, .gallery-item'
).forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(24px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});
// Lightbox
const lightbox = document.createElement('div');
lightbox.id = 'lightbox';
lightbox.innerHTML = '<img /><span class="lightbox-close">×</span>';
document.body.appendChild(lightbox);
const lbImg = lightbox.querySelector('img');
const lbClose = lightbox.querySelector('.lightbox-close');
document.querySelectorAll('.gallery-item img, .project-image img').forEach(img => {
img.style.cursor = 'zoom-in';
img.addEventListener('click', () => {
lbImg.src = img.src;
lbImg.alt = img.alt;
lightbox.classList.add('open');
document.body.style.overflow = 'hidden';
});
});
function closeLightbox() {
lightbox.classList.remove('open');
document.body.style.overflow = '';
}
lbClose.addEventListener('click', closeLightbox);
lightbox.addEventListener('click', e => {
if (e.target === lightbox) closeLightbox();
});
document.addEventListener('keydown', e => {
if (e.key === 'Escape') closeLightbox();
});