Skip to content

Commit 8d038e3

Browse files
BartDelruefeimosi
authored andcommitted
(feat) Add home/end key support
1 parent 862b2b7 commit 8d038e3

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/baguetteBox.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@
307307
case 27: // Esc
308308
hideOverlay();
309309
break;
310+
case 36: // Home
311+
showFirstImage(event);
312+
break;
313+
case 35: // End
314+
showLastImage(event);
315+
break;
310316
}
311317
}
312318

@@ -598,6 +604,22 @@
598604
return show(currentIndex - 1);
599605
}
600606

607+
// Return false at the left end of the gallery
608+
function showFirstImage(event) {
609+
if (event) {
610+
event.preventDefault();
611+
}
612+
return show(0);
613+
}
614+
615+
// Return false at the right end of the gallery
616+
function showLastImage(event) {
617+
if (event) {
618+
event.preventDefault();
619+
}
620+
return show(currentGallery.length - 1);
621+
}
622+
601623
/**
602624
* Move the gallery to a specific index
603625
* @param `index` {number} - the position of the image

0 commit comments

Comments
 (0)