adding script to close overlay with esc
This commit is contained in:
@@ -471,3 +471,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- optional js : pressing Escape closes the lightbox by clicking the same
|
||||||
|
close link as the button. a real fragment navigation is required:
|
||||||
|
history.pushState() alone changes the url but does NOT update :target,
|
||||||
|
so the pure-css overlay would stay open. to disable, wrap the <script>
|
||||||
|
block below in an html comment again -->
|
||||||
|
<script>
|
||||||
|
document.addEventListener("keydown", function (event) {
|
||||||
|
if (
|
||||||
|
event.key === "Escape" &&
|
||||||
|
document.querySelector(".lightbox_list :target")
|
||||||
|
) {
|
||||||
|
document.querySelector(".lightbox_close").click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user