document.addEventListener("DOMContentLoaded", run); // global var to control the animation of the text var runTextAnimation = true; function run() { initializeClickHandler(); } function initializeClickHandler() { let welcome = document.getElementById("welcome"); flyingText(welcome); document.addEventListener("click", (e) => { let overlay = document.getElementById("info-box"); let curr = e.target; if (curr.className === "thumb") { runTextAnimation = false; hideElement(welcome); handleThumb(overlay, curr); } else if (curr.id === "btn-close") { runTextAnimation = true; flyingText(welcome); hideElement(overlay); } }); } function handleThumb(overlay, elem) { let imgName = elem.dataset.img; showOverlay(overlay, imgName); } function showOverlay(overlay, imgName) { let info = getInfoForImg(imgName); // \xD7 is the multiplication sign in hex overlay.children[0].innerHTML = `
Author: | ${info.author} |
---|---|
Size: | ${info.size} |
Tools: | ${info.tools} |
Date: | ${info.date} |
Price: | ${info.price} |
Description: | |
${info.desc} | |
Read more... |