@@ -27,8 +27,8 @@ const { projects } = Astro.props;
2727 <!-- Close Button -->
2828 <button
2929 type = " button"
30- class = " absolute top-4 right-4 text-white hover:text-gray-300 z-10 bg-black/30 rounded-full p-2 backdrop-blur-sm transition-colors"
31- onclick = { ` event.stopPropagation(); closeImageGallery('${ project .id }') ` }
30+ class = " gallery-close-btn absolute top-4 right-4 text-white hover:text-gray-300 z-10 bg-black/30 rounded-full p-2 backdrop-blur-sm transition-colors"
31+ data-gallery-id = { project .id }
3232 >
3333 <svg class = " w-6 h-6" fill = " none" stroke = " currentColor" viewBox = " 0 0 24 24" >
3434 <path stroke-linecap = " round" stroke-linejoin = " round" stroke-width = " 2" d = " M6 18L18 6M6 6l12 12" ></path >
@@ -40,8 +40,8 @@ const { projects } = Astro.props;
4040 <>
4141 <button
4242 type = " button"
43- class = " absolute left-4 top-1/2 transform -translate-y-1/2 text-white hover:text-gray-300 z-10 bg-black/30 rounded-full p-3 backdrop-blur-sm transition-colors hover:bg-black/50"
44- onclick = { ` event.stopPropagation(); navigateGallery('${ project .id }', -1) ` }
43+ class = " gallery-prev-btn absolute left-4 top-1/2 transform -translate-y-1/2 text-white hover:text-gray-300 z-10 bg-black/30 rounded-full p-3 backdrop-blur-sm transition-colors hover:bg-black/50"
44+ data-gallery-id = { project .id }
4545 >
4646 <svg class = " w-8 h-8" fill = " none" stroke = " currentColor" viewBox = " 0 0 24 24" >
4747 <path stroke-linecap = " round" stroke-linejoin = " round" stroke-width = " 3" d = " M15 19l-7-7 7-7" ></path >
@@ -50,8 +50,8 @@ const { projects } = Astro.props;
5050
5151 <button
5252 type = " button"
53- class = " absolute right-4 top-1/2 transform -translate-y-1/2 text-white hover:text-gray-300 z-10 bg-black/30 rounded-full p-3 backdrop-blur-sm transition-colors hover:bg-black/50"
54- onclick = { ` event.stopPropagation(); navigateGallery('${ project .id }', 1) ` }
53+ class = " gallery-next-btn absolute right-4 top-1/2 transform -translate-y-1/2 text-white hover:text-gray-300 z-10 bg-black/30 rounded-full p-3 backdrop-blur-sm transition-colors hover:bg-black/50"
54+ data-gallery-id = { project .id }
5555 >
5656 <svg class = " w-8 h-8" fill = " none" stroke = " currentColor" viewBox = " 0 0 24 24" >
5757 <path stroke-linecap = " round" stroke-linejoin = " round" stroke-width = " 3" d = " M9 5l7 7-7 7" ></path >
@@ -61,7 +61,7 @@ const { projects } = Astro.props;
6161 )}
6262
6363 <!-- Image Container -->
64- <div class = " relative flex items-center justify-center max-w-full max-h-full" onclick = " event.stopPropagation() " >
64+ <div class = " gallery-image-container relative flex items-center justify-center max-w-full max-h-full" >
6565 <img
6666 id = { ` gallery-image-${project .id } ` }
6767 src = " "
@@ -84,7 +84,7 @@ const { projects } = Astro.props;
8484 // Global gallery functions
8585 window.openImageGallery = function(id, index = 0) {
8686 const modal = document.getElementById(`gallery-modal-${id}`);
87- const image = document.getElementById(`gallery-image-${id}`);
87+ const image = document.getElementById(`gallery-image-${id}`) as HTMLImageElement ;
8888 const counter = document.getElementById(`gallery-counter-${id}`);
8989
9090 if (modal && image && window.galleryData && window.galleryData[id]) {
@@ -143,4 +143,41 @@ const { projects } = Astro.props;
143143 break;
144144 }
145145 });
146+
147+ // Setup event listeners for all gallery buttons
148+ document.addEventListener('DOMContentLoaded', function() {
149+ // Close buttons
150+ document.querySelectorAll('.gallery-close-btn').forEach(btn => {
151+ btn.addEventListener('click', function(e: Event) {
152+ e.stopPropagation();
153+ const id = (e.currentTarget as HTMLElement).getAttribute('data-gallery-id');
154+ if (id) window.closeImageGallery(id);
155+ });
156+ });
157+
158+ // Previous buttons
159+ document.querySelectorAll('.gallery-prev-btn').forEach(btn => {
160+ btn.addEventListener('click', function(e: Event) {
161+ e.stopPropagation();
162+ const id = (e.currentTarget as HTMLElement).getAttribute('data-gallery-id');
163+ if (id) window.navigateGallery(id, -1);
164+ });
165+ });
166+
167+ // Next buttons
168+ document.querySelectorAll('.gallery-next-btn').forEach(btn => {
169+ btn.addEventListener('click', function(e: Event) {
170+ e.stopPropagation();
171+ const id = (e.currentTarget as HTMLElement).getAttribute('data-gallery-id');
172+ if (id) window.navigateGallery(id, 1);
173+ });
174+ });
175+
176+ // Image containers - prevent clicks from closing modal
177+ document.querySelectorAll('.gallery-image-container').forEach(container => {
178+ container.addEventListener('click', function(e: Event) {
179+ e.stopPropagation();
180+ });
181+ });
182+ });
146183</script >
0 commit comments