diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-22 15:29:12 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-22 15:29:12 +0200 |
commit | 825a69b1866e98db181e5e6dec4e6c879eeac79d (patch) | |
tree | 58e377698be4058cb529557e2ec69d27892d1512 /web | |
parent | d729b5199cd8740ef203b509079dd2aed0d70e23 (diff) | |
download | jellything-825a69b1866e98db181e5e6dec4e6c879eeac79d.tar jellything-825a69b1866e98db181e5e6dec4e6c879eeac79d.tar.bz2 jellything-825a69b1866e98db181e5e6dec4e6c879eeac79d.tar.zst |
generalize transitions
Diffstat (limited to 'web')
m--------- | web/script/jshelper | 0 | ||||
-rw-r--r-- | web/script/transition.ts | 9 |
2 files changed, 3 insertions, 6 deletions
diff --git a/web/script/jshelper b/web/script/jshelper -Subproject bd8b233316820cd35178085ef132f82279be050 +Subproject 2d36b0762459b8edfc1529827d0c15447edd266 diff --git a/web/script/transition.ts b/web/script/transition.ts index 2bf2a7b..00ed9a7 100644 --- a/web/script/transition.ts +++ b/web/script/transition.ts @@ -8,14 +8,12 @@ import { e } from "./jshelper/src/element.ts"; const duration = 200 -globalThis.addEventListener("load", () => { +globalThis.addEventListener("DOMContentLoaded", () => { patch_page() }) globalThis.addEventListener("popstate", async (_e) => { - const had_disable_transition = disable_transition; await transition_to(window.location.href, true) - if (had_disable_transition) window.location.reload() }) let disable_transition = false @@ -26,7 +24,6 @@ globalThis.addEventListener("navigationrequiresreload", () => { function patch_page() { document.querySelectorAll("a").forEach(el => { el.addEventListener("click", async ev => { - if (disable_transition) return ev.preventDefault() await transition_to(el.href) }) @@ -34,10 +31,12 @@ function patch_page() { } async function transition_to(href: string, back?: boolean) { + if (disable_transition) return window.location.href = href const trigger_load = prepare_load(href, back) await fade(false) trigger_load() disable_transition = false; + await fade(true) } function show_error(mesg: string) { @@ -61,8 +60,6 @@ function prepare_load(href: string, back?: boolean) { document.head.innerHTML = head document.body.outerHTML = body globalThis.dispatchEvent(new Event("DOMContentLoaded")) - fade(true) - patch_page() } } |