add image fade in
This commit is contained in:
parent
f4e95f987d
commit
96bcd73a0e
3 changed files with 41 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { expandNav, closeNav } from "./functions.js";
|
||||
import { expandNav, closeNav, show } from "./functions.js";
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Variables
|
||||
|
|
@ -10,6 +10,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
footer: document.querySelector(".main-footer"),
|
||||
nav: document.querySelector(".main-nav"),
|
||||
jsLinks: document.querySelectorAll(".js-link"),
|
||||
images: document.querySelectorAll("img"),
|
||||
};
|
||||
|
||||
// Listeners
|
||||
|
|
@ -20,6 +21,16 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
jsLink.addEventListener("click", () => (location.href = to));
|
||||
});
|
||||
|
||||
nodes.images.forEach((image) => {
|
||||
if (image.complete) {
|
||||
show(image);
|
||||
} else {
|
||||
image.addEventListener("load", () => {
|
||||
show(image);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Key shortcuts
|
||||
window.addEventListener("keyup", (event) => {
|
||||
if (event.key === "Escape") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue