Merge pull request #475 from h3poteto/fix/jump

Use vue-shortkey in jump modal because sometimes jump modal is freeze
This commit is contained in:
AkiraFukushima 2018-08-08 22:37:09 +09:00 committed by GitHub
commit aeebdd644a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 1 deletions

View File

@ -5,7 +5,14 @@
class="jump-modal">
<el-form class="jump-form" v-on:submit.prevent="jump">
<div class="channel">
<input type="text" v-model="channel" placeholder="Jump to..." ref="channel" @keyup.enter.exact="jumpCurrentSelected" @keyup.down.exact="nextChannel" @keyup.up.exact="prevChannel" />
<input
type="text"
v-model="channel"
placeholder="Jump to..."
ref="channel"
v-shortkey="{next: ['arrowdown'], prev: ['arrowup'], select: ['enter']}"
@shortkey="handleKey"
/>
<ul class="channel-list">
<li v-for="c in filterdChannel" :class="c.name === selectedChannel.name ? 'channel-list-item selected' : 'channel-list-item'" @click="jump(c)" @mouseover="changeSelected(c)">{{ c.name }}</li>
</ul>
@ -93,10 +100,26 @@ export default {
this.$store.commit('TimelineSpace/Modals/Jump/changeSelected', channel)
},
jumpCurrentSelected () {
console.log('catch')
this.$store.dispatch('TimelineSpace/Modals/Jump/jumpCurrentSelected')
},
jump (channel) {
this.$store.dispatch('TimelineSpace/Modals/Jump/jump', channel)
},
handleKey (event) {
switch (event.srcKey) {
case 'next':
this.nextChannel()
break
case 'prev':
this.prevChannel()
break
case 'select':
this.jumpCurrentSelected()
break
default:
return true
}
}
}
}