mirror of
https://github.com/thelounge/thelounge
synced 2025-02-16 21:28:23 +00:00
Use mousetrap for escape binds
This commit is contained in:
parent
0cb8dc73bb
commit
9147772cb2
2 changed files with 14 additions and 10 deletions
|
@ -38,11 +38,7 @@ export default {
|
|||
};
|
||||
},
|
||||
mounted() {
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.code === "Escape") {
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
Mousetrap.bind("esc", this.close);
|
||||
|
||||
const trap = Mousetrap(this.$refs.contextMenu);
|
||||
|
||||
|
@ -78,6 +74,9 @@ export default {
|
|||
return false;
|
||||
});
|
||||
},
|
||||
destroyed() {
|
||||
Mousetrap.unbind("esc", this.close);
|
||||
},
|
||||
methods: {
|
||||
open(event, items) {
|
||||
this.items = items;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import Mousetrap from "mousetrap";
|
||||
|
||||
export default {
|
||||
name: "ImageViewer",
|
||||
data() {
|
||||
|
@ -61,14 +63,17 @@ export default {
|
|||
},
|
||||
},
|
||||
mounted() {
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.code === "Escape") {
|
||||
this.closeViewer();
|
||||
}
|
||||
});
|
||||
Mousetrap.bind("esc", this.closeViewer);
|
||||
},
|
||||
destroyed() {
|
||||
Mousetrap.unbind("esc", this.closeViewer);
|
||||
},
|
||||
methods: {
|
||||
closeViewer() {
|
||||
if (this.link === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$root.$off("resize", this.correctPosition);
|
||||
this.link = null;
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue