-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (51 loc) · 1.78 KB
/
script.js
File metadata and controls
58 lines (51 loc) · 1.78 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
document.addEventListener('DOMContentLoaded', () => {
// Scroll reveal animation using Intersection Observer
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.15
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
// Optional: Stop observing once revealed
// observer.unobserve(entry.target);
}
});
}, observerOptions);
// Initial check for elements in viewport
setTimeout(() => {
document.querySelectorAll('.animate-on-scroll').forEach(el => {
observer.observe(el);
// If already in viewport on load, show it
const rect = el.getBoundingClientRect();
if(rect.top < window.innerHeight) {
el.classList.add('visible');
}
});
}, 100);
// Lightbox logic
const lightbox = document.getElementById('lightbox');
const lightboxImg = document.getElementById('lightbox-img');
const closeBtn = document.querySelector('.close-lightbox');
document.querySelectorAll('.screenshot-img').forEach(img => {
// Add click listener
img.addEventListener('click', function() {
lightbox.classList.add('active');
lightboxImg.src = this.src;
});
});
if (closeBtn) {
closeBtn.addEventListener('click', () => {
lightbox.classList.remove('active');
});
}
if (lightbox) {
lightbox.addEventListener('click', (e) => {
if (e.target !== lightboxImg) {
lightbox.classList.remove('active');
}
});
}
});