escape images with escape
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 28s
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 28s
This commit is contained in:
parent
bb6c8ad993
commit
0a18da80c2
1 changed files with 8 additions and 0 deletions
|
|
@ -2,6 +2,14 @@ const backdrop = document.querySelector("#image-backdrop");
|
||||||
const preview = document.querySelector("#image-preview");
|
const preview = document.querySelector("#image-preview");
|
||||||
|
|
||||||
if (backdrop instanceof HTMLElement && preview instanceof HTMLImageElement) {
|
if (backdrop instanceof HTMLElement && preview instanceof HTMLImageElement) {
|
||||||
|
|
||||||
|
document.addEventListener("keydown", (event) => {
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
backdrop.hidden = true;
|
||||||
|
document.body.style.overflow = "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
document.addEventListener("click", (event) => {
|
document.addEventListener("click", (event) => {
|
||||||
if (!(event.target instanceof Element)) return;
|
if (!(event.target instanceof Element)) return;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue