-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgallery.html
More file actions
167 lines (154 loc) · 7.05 KB
/
Copy pathgallery.html
File metadata and controls
167 lines (154 loc) · 7.05 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gallery - Timur Gabaidulin</title>
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=Fira+Sans:wght@300..900&display=swap" rel="stylesheet">
</head>
<body class="gallery-page">
<header class="header">
<nav class="navbar">
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="words.html">Words</a>
<a href="projects.html">Projects</a>
<a href="gallery.html" class="active">Gallery</a>
</nav>
</header>
<main class="gallery-container">
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal3.jpg" alt="Gallery Image 3" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal4.jpg" alt="Gallery Image 4" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal5.jpg" alt="Gallery Image 5" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal6.jpg" alt="Gallery Image 6" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal7.jpg" alt="Gallery Image 7" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal8.jpg" alt="Gallery Image 8" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal9.jpg" alt="Gallery Image 9" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal10.jpg" alt="Gallery Image 10" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal11.jpg" alt="Gallery Image 11" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal12.jpg" alt="Gallery Image 12" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal13.jpg" alt="Gallery Image 13" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal14.jpg" alt="Gallery Image 14" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal15.jpg" alt="Gallery Image 15" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal16.jpg" alt="Gallery Image 16" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal17.jpg" alt="Gallery Image 17" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal18.jpg" alt="Gallery Image 18" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal19.jpg" alt="Gallery Image 19" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal20.jpg" alt="Gallery Image 20" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal21.jpg" alt="Gallery Image 21" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal22.jpg" alt="Gallery Image 22" loading="lazy">
</div>
<div class="gallery-item" tabindex="0">
<img src="images/gallery/gal23.jpg" alt="Gallery Image 23" loading="lazy">
</div>
</main>
<div class="lightbox" id="lightbox" role="dialog" aria-modal="true">
<button class="lightbox-nav prev" id="prev-btn" aria-label="Previous image"><</button>
<img src="" alt="Lightbox Image" id="lightbox-img">
<button class="lightbox-nav next" id="next-btn" aria-label="Next image">></button>
<button class="lightbox-close" id="close-btn" aria-label="Close lightbox">×</button>
</div>
<footer class="footer">
<p>© 2024 Timur Gabaidulin. Template licensed under <a href="copyright.html" target="_blank">MIT License</a>.</p>
<p>Icons by <a href="https://fontawesome.com/" target="_blank">FontAwesome</a></p>
</footer>
<script>
const galleryItems = document.querySelectorAll('.gallery-item');
const lightbox = document.getElementById('lightbox');
const lightboxImg = document.getElementById('lightbox-img');
const prevBtn = document.getElementById('prev-btn');
const nextBtn = document.getElementById('next-btn');
const closeBtn = document.getElementById('close-btn');
let currentIndex = 0;
function showImage(index) {
const imgSrc = galleryItems[index].querySelector('img').src;
lightboxImg.src = imgSrc;
lightboxImg.alt = galleryItems[index].querySelector('img').alt;
currentIndex = index;
}
function openLightbox(index) {
showImage(index);
lightbox.classList.add('active');
document.body.style.overflow = 'hidden';
}
function closeLightbox() {
lightbox.classList.remove('active');
document.body.style.overflow = '';
}
galleryItems.forEach((item, index) => {
item.addEventListener('click', () => openLightbox(index));
item.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
openLightbox(index);
}
});
});
prevBtn.addEventListener('click', (e) => {
e.stopPropagation();
currentIndex = (currentIndex - 1 + galleryItems.length) % galleryItems.length;
showImage(currentIndex);
});
nextBtn.addEventListener('click', (e) => {
e.stopPropagation();
currentIndex = (currentIndex + 1) % galleryItems.length;
showImage(currentIndex);
});
closeBtn.addEventListener('click', closeLightbox);
lightbox.addEventListener('click', (e) => {
if (e.target === lightbox) {
closeLightbox();
}
});
document.addEventListener('keydown', (e) => {
if (!lightbox.classList.contains('active')) return;
if (e.key === 'ArrowLeft') prevBtn.click();
if (e.key === 'ArrowRight') nextBtn.click();
if (e.key === 'Escape') closeLightbox();
});
</script>
</body>
</html>