mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-24 21:43:00 +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 image_src = "";
|
||||
|
||||
public created() {
|
||||
window.addEventListener("keydown", (e) => {
|
||||
if (e.key == "Escape") this.set_active(false);
|
||||
});
|
||||
private on_keydown(e: KeyboardEvent) {
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue