Skip to content

Commit 23a445c

Browse files
committed
added gakllery effect
1 parent bfabe42 commit 23a445c

File tree

3 files changed

+134
-10
lines changed

3 files changed

+134
-10
lines changed

assets/css/main.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,3 +2385,63 @@ body.modal-open {
23852385
font-size: 1em;
23862386
}
23872387
}
2388+
2389+
/* Navigation arrows */
2390+
.modal-nav {
2391+
cursor: pointer;
2392+
position: absolute;
2393+
top: 50%;
2394+
width: auto;
2395+
margin-top: -22px;
2396+
padding: 16px;
2397+
color: white;
2398+
font-weight: bold;
2399+
font-size: 24px;
2400+
transition: 0.3s ease;
2401+
border-radius: 0 3px 3px 0;
2402+
user-select: none;
2403+
background-color: rgba(0, 0, 0, 0.5);
2404+
z-index: 10003;
2405+
}
2406+
2407+
.modal-prev {
2408+
left: 20px;
2409+
border-radius: 3px 0 0 3px;
2410+
}
2411+
2412+
.modal-next {
2413+
right: 20px;
2414+
border-radius: 0 3px 3px 0;
2415+
}
2416+
2417+
.modal-nav:hover {
2418+
background-color: rgba(0, 0, 0, 0.8);
2419+
color: #f56a6a;
2420+
}
2421+
2422+
.modal-nav.disabled {
2423+
color: #666;
2424+
cursor: not-allowed;
2425+
background-color: rgba(0, 0, 0, 0.2);
2426+
}
2427+
2428+
.modal-nav.disabled:hover {
2429+
background-color: rgba(0, 0, 0, 0.2);
2430+
color: #666;
2431+
}
2432+
2433+
@media screen and (max-width: 736px) {
2434+
.modal-nav {
2435+
font-size: 18px;
2436+
padding: 12px;
2437+
margin-top: -18px;
2438+
}
2439+
2440+
.modal-prev {
2441+
left: 10px;
2442+
}
2443+
2444+
.modal-next {
2445+
right: 10px;
2446+
}
2447+
}

assets/js/image-modal.js

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
var captionText = $('#caption');
88
var closeBtn = $('.close');
99

10+
// Gallery state
11+
var currentImageIndex = 0;
12+
var imageElements = [];
13+
1014
// Transform state
1115
var scale = 1;
1216
var translateX = 0;
@@ -30,14 +34,76 @@
3034
updateTransform();
3135
}
3236

37+
function showImage(index) {
38+
if (index < 0 || index >= imageElements.length) return;
39+
40+
currentImageIndex = index;
41+
var img = imageElements[index];
42+
var fullSrc = $(img).data('full') || img.src;
43+
44+
modalImg.attr('src', fullSrc);
45+
captionText.text($(img).attr('alt') + ` (${index + 1} of ${imageElements.length})`);
46+
resetTransform();
47+
48+
// Update navigation button states
49+
updateNavigationButtons();
50+
}
51+
52+
function updateNavigationButtons() {
53+
$('.modal-prev').toggleClass('disabled', currentImageIndex === 0);
54+
$('.modal-next').toggleClass('disabled', currentImageIndex === imageElements.length - 1);
55+
}
56+
57+
function goToPrevious() {
58+
if (currentImageIndex > 0) {
59+
showImage(currentImageIndex - 1);
60+
}
61+
}
62+
63+
function goToNext() {
64+
if (currentImageIndex < imageElements.length - 1) {
65+
showImage(currentImageIndex + 1);
66+
}
67+
}
68+
69+
// Initialize gallery - collect all images on page load
70+
function initializeGallery() {
71+
imageElements = $('.image.fit img, .image.main img').get();
72+
}
73+
3374
// Add click event to all images
34-
$('.image.fit img, .image.main img').on('click', function() {
75+
$(document).on('click', '.image.fit img, .image.main img', function() {
76+
initializeGallery();
77+
currentImageIndex = imageElements.indexOf(this);
3578
modal.show();
36-
modalImg.attr('src', this.src);
37-
captionText.text($(this).attr('alt'));
38-
resetTransform();
79+
showImage(currentImageIndex);
80+
$('body').addClass('modal-open');
81+
});
82+
83+
// Keyboard navigation
84+
$(document).on('keydown', function(e) {
85+
if (!modal.is(':visible')) return;
86+
87+
switch(e.key) {
88+
case 'Escape':
89+
modal.hide();
90+
$('body').removeClass('modal-open');
91+
break;
92+
case 'ArrowLeft':
93+
e.preventDefault();
94+
goToPrevious();
95+
break;
96+
case 'ArrowRight':
97+
e.preventDefault();
98+
goToNext();
99+
break;
100+
}
39101
});
40102

103+
// Navigation button events
104+
$(document).on('click', '.modal-prev:not(.disabled)', goToPrevious);
105+
$(document).on('click', '.modal-next:not(.disabled)', goToNext);
106+
41107
// Mouse wheel zoom
42108
modalImg.on('wheel', function(e) {
43109
e.preventDefault();
@@ -132,17 +198,13 @@
132198
// Close modal events
133199
closeBtn.on('click', function() {
134200
modal.hide();
201+
$('body').removeClass('modal-open');
135202
});
136203

137204
modal.on('click', function(event) {
138205
if (event.target === this) {
139206
modal.hide();
140-
}
141-
});
142-
143-
$(document).on('keydown', function(e) {
144-
if (e.key === 'Escape') {
145-
modal.hide();
207+
$('body').removeClass('modal-open');
146208
}
147209
});
148210
});

experiments/umbrella-girl.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ <h2>Menu</h2>
266266
<!-- Image Modal -->
267267
<div id="imageModal" class="modal">
268268
<span class="close">&times;</span>
269+
<div class="modal-nav modal-prev">&#10094;</div>
270+
<div class="modal-nav modal-next">&#10095;</div>
269271
<img class="modal-content" id="modalImage">
270272
<div id="caption"></div>
271273
</div>

0 commit comments

Comments
 (0)