From: Lanius Trolling Date: Tue, 18 Jul 2023 17:53:58 +0000 (-0400) Subject: Allow images to be viewed full-size before page is done loading X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=c0afbc58133f5848700a23a03d9dde4124c9c030;p=factbooks Allow images to be viewed full-size before page is done loading --- diff --git a/src/main/kotlin/info/mechyrdia/lore/view_tpl.kt b/src/main/kotlin/info/mechyrdia/lore/view_tpl.kt index 19c576d..cecf7f3 100644 --- a/src/main/kotlin/info/mechyrdia/lore/view_tpl.kt +++ b/src/main/kotlin/info/mechyrdia/lore/view_tpl.kt @@ -96,6 +96,12 @@ fun ApplicationCall.page(pageTitle: String, navBar: List? = null, sideb } } + script { + unsafe { + raw("window.handleFullSizeImages();") + } + } + request.queryParameters["error"]?.let { errorMessage -> div { id = "error-popup" diff --git a/src/main/resources/static/init.js b/src/main/resources/static/init.js index e73d7bf..a854c9f 100644 --- a/src/main/resources/static/init.js +++ b/src/main/resources/static/init.js @@ -97,7 +97,7 @@ document.currentScript.after(imgElement); }; - window.addEventListener("load", function () { + window.handleFullSizeImages = function () { // Image previewing (2) document.getElementById("thumb-view").addEventListener("click", e => { e.preventDefault(); @@ -105,7 +105,7 @@ e.currentTarget.classList.remove("visible"); e.currentTarget.getElementsByTagName("img")[0].src = ""; }); - }); + }; window.addEventListener("load", function () { // Mesh viewing