mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
cleanup event listener in MultiModal
This commit is contained in:
parent
b30e8095f9
commit
08972df4cc
1 changed files with 10 additions and 4 deletions
|
@ -23,10 +23,16 @@ export default class extends Vue {
|
||||||
public progress = false;
|
public progress = false;
|
||||||
public image_src = "";
|
public image_src = "";
|
||||||
|
|
||||||
public created() {
|
private on_keydown(e: KeyboardEvent) {
|
||||||
window.addEventListener("keydown", (e) => {
|
if (e.key == "Escape") this.set_active(false);
|
||||||
if (e.key == "Escape") this.set_active(false);
|
}
|
||||||
});
|
|
||||||
|
public mounted(): void {
|
||||||
|
window.addEventListener("keydown", this.on_keydown);
|
||||||
|
}
|
||||||
|
|
||||||
|
public beforeUnmount(): void {
|
||||||
|
window.removeEventListener("keydown", this.on_keydown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public set_active(state: boolean) {
|
public set_active(state: boolean) {
|
||||||
|
|
Loading…
Reference in a new issue