add keyup to close modal
This commit is contained in:
parent
230e9e6560
commit
18926dd58a
|
@ -40,6 +40,7 @@
|
||||||
hideSettings() { this.active = false },
|
hideSettings() { this.active = false },
|
||||||
toggleSettings() { this.active = !this.active },
|
toggleSettings() { this.active = !this.active },
|
||||||
keyupListener(e) {
|
keyupListener(e) {
|
||||||
|
if (document.getElementsByClassName('bd-backdrop').length) return;
|
||||||
if (this.active && e.which === 27) return this.hideSettings();
|
if (this.active && e.which === 27) return this.hideSettings();
|
||||||
if (!e.metaKey && !e.ctrlKey || e.key !== 'b') return;
|
if (!e.metaKey && !e.ctrlKey || e.key !== 'b') return;
|
||||||
this.toggleSettings();
|
this.toggleSettings();
|
||||||
|
|
|
@ -44,6 +44,20 @@
|
||||||
return {
|
return {
|
||||||
scrolled: false
|
scrolled: false
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
beforeMount() {
|
||||||
|
window.addEventListener('keyup', this.keyupListener);
|
||||||
|
},
|
||||||
|
destroyed() {
|
||||||
|
window.removeEventListener('keyup', this.keyupListener);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
keyupListener(e) {
|
||||||
|
console.log('key up!');
|
||||||
|
if (e.which === 27) {
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue