Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
feat: use the left and right arrows on the keyboard to switch between…
Browse files Browse the repository at this point in the history
… the plugin images (#1831)
  • Loading branch information
brenopolanski authored Mar 14, 2020
1 parent cc82944 commit 0028132
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ export default {
sliderClass: 'slides-right'
}),
mounted () {
document.addEventListener('keyup', this.onArrowKeys, false)
},
destroyed () {
document.removeEventListener('keyup', this.onArrowKeys)
},
methods: {
emitClose () {
this.$emit('close')
Expand Down Expand Up @@ -144,6 +152,16 @@ export default {
this.isTransitioning = true
this.currentIndex = page - 1
},
onArrowKeys (event) {
if (event.key === 'ArrowLeft') {
this.transitionEnd()
this.previousImage()
} else if (event.key === 'ArrowRight') {
this.transitionEnd()
this.nextImage()
}
}
}
}
Expand Down

0 comments on commit 0028132

Please sign in to comment.