add keyboard navigation
This commit is contained in:
parent
b0d3281149
commit
f61d1e0d45
1 changed files with 12 additions and 0 deletions
|
@ -79,6 +79,18 @@ function loadGallery(images, idx) {
|
|||
const thumbnailsContainer = gallery.querySelector(".thumbnails");
|
||||
const download = gallery.querySelector(".download");
|
||||
|
||||
gallery.addEventListener("keydown", event => {
|
||||
if (event.keyCode == 39) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
nextBtn.onclick(event)
|
||||
} else if (event.keyCode == 37) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
prevBtn.onclick(event)
|
||||
}
|
||||
})
|
||||
|
||||
function updateGallery(index) {
|
||||
mainImage.src = images[index].src.replace('_display', '_thumbnail');
|
||||
setTimeout(() => {
|
||||
|
|
Loading…
Add table
Reference in a new issue