-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
44 lines (39 loc) · 1.28 KB
/
script.js
File metadata and controls
44 lines (39 loc) · 1.28 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
// JavaScript for smooth page transitions
document.querySelectorAll('a').forEach(anchor => {
anchor.addEventListener('click', function(event) {
if (this.href !== window.location.href) {
event.preventDefault();
document.body.classList.add('fade-out');
setTimeout(() => {
window.location.href = this.href;
}, 500);
}
});
});
window.addEventListener('pageshow', (event) => {
if (event.persisted) {
document.body.classList.remove('fade-out');
}
});
function openLightbox(src) {
const lightbox = document.getElementById('lightbox');
const lightboxImg = document.getElementById('lightbox-img');
lightbox.style.display = 'flex';
lightboxImg.src = src;
}
function closeLightbox() {
const lightbox = document.getElementById('lightbox');
lightbox.style.display = 'none';
}
// Attach click events to all images in the gallery
document.querySelectorAll('.design-item img').forEach(img => {
img.addEventListener('click', function() {
openLightbox(this.src);
});
});
// Optional: Close lightbox when clicking outside the image
document.getElementById('lightbox').addEventListener('click', function(event) {
if (event.target === this) {
closeLightbox();
}
});