refs #3300 Handle shortcut keys in ImageViewer

This commit is contained in:
AkiraFukushima 2022-05-03 01:53:13 +09:00
parent 105acd8337
commit 3443c20e16
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
1 changed files with 12 additions and 0 deletions

View File

@ -23,6 +23,7 @@
<script lang="ts">
import { defineComponent, computed } from 'vue'
import { useMagicKeys, whenever } from '@vueuse/core'
import { useStore } from '@/store'
import { ACTION_TYPES } from '@/store/TimelineSpace/Modals/ImageViewer'
import Media from './ImageViewer/Media.vue'
@ -35,6 +36,7 @@ export default defineComponent({
setup() {
const space = 'TimelineSpace/Modals/ImageViewer'
const store = useStore()
const { left, right, Escape } = useMagicKeys()
const modalOpen = computed(() => store.state.TimelineSpace.Modals.ImageViewer.modalOpen)
const imageURL = computed(() => store.getters[`${space}/imageURL`])
@ -42,6 +44,16 @@ export default defineComponent({
const showLeft = computed(() => store.getters[`${space}/showLeft`])
const showRight = computed(() => store.getters[`${space}/showRight`])
whenever(left, () => {
decrementIndex()
})
whenever(right, () => {
incrementIndex()
})
whenever(Escape, () => {
close()
})
const close = () => {
store.dispatch(`${space}/${ACTION_TYPES.CLOSE_MODAL}`)
}