Skip to content

Commit

Permalink
(feat) Add home/end key support
Browse files Browse the repository at this point in the history
  • Loading branch information
BartDelrue authored and feimosi committed Sep 16, 2018
1 parent 862b2b7 commit 8d038e3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/baguetteBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@
case 27: // Esc
hideOverlay();
break;
case 36: // Home
showFirstImage(event);
break;
case 35: // End
showLastImage(event);
break;
}
}

Expand Down Expand Up @@ -598,6 +604,22 @@
return show(currentIndex - 1);
}

// Return false at the left end of the gallery
function showFirstImage(event) {
if (event) {
event.preventDefault();
}
return show(0);
}

// Return false at the right end of the gallery
function showLastImage(event) {
if (event) {
event.preventDefault();
}
return show(currentGallery.length - 1);
}

/**
* Move the gallery to a specific index
* @param `index` {number} - the position of the image
Expand Down

0 comments on commit 8d038e3

Please sign in to comment.