Fix player keyboard interaction

This commit is contained in:
James Lyne 2021-05-26 18:49:11 +01:00
parent c9fbe61d2b
commit a05cfde9d7

View File

@ -19,8 +19,7 @@
<img width="16" height="16" class="player__icon" :src="image" alt="" aria-hidden="true" /> <img width="16" height="16" class="player__icon" :src="image" alt="" aria-hidden="true" />
<button class="player__name" type="button" :title="title" <button class="player__name" type="button" :title="title"
:disbled="player.hidden" :disbled="player.hidden"
@click.prevent="pan" @click.prevent="onClick"
@keydown="onKeydown"
@dblclick.prevent="follow" v-html="player.name"></button> @dblclick.prevent="follow" v-html="player.name"></button>
</li> </li>
</template> </template>
@ -60,6 +59,7 @@ export default defineComponent({
pan = () => { pan = () => {
if(!props.player.hidden) { if(!props.player.hidden) {
console.log('clear?');
store.commit(MutationTypes.CLEAR_FOLLOW_TARGET, undefined); store.commit(MutationTypes.CLEAR_FOLLOW_TARGET, undefined);
store.commit(MutationTypes.SET_PAN_TARGET, props.player); store.commit(MutationTypes.SET_PAN_TARGET, props.player);
} }
@ -67,18 +67,13 @@ export default defineComponent({
follow = () => store.commit(MutationTypes.SET_FOLLOW_TARGET, props.player), follow = () => store.commit(MutationTypes.SET_FOLLOW_TARGET, props.player),
onKeydown = (e: KeyboardEvent) => { onClick = (e: MouseEvent) => {
if(e.key !== ' ' && e.key !== 'Enter') {
return;
}
if(e.shiftKey) { if(e.shiftKey) {
follow(); follow();
e.preventDefault();
} else { } else {
if(!props.player.hidden) {
pan(); pan();
} }
}
}; };
let image = ref(defaultImage); let image = ref(defaultImage);
@ -95,7 +90,7 @@ export default defineComponent({
otherWorld, otherWorld,
pan, pan,
follow, follow,
onKeydown onClick
} }
}, },