From f302717a59c4eb08ee0c97acc87f01d8cd50f39f Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 22 Mar 2026 04:40:49 +0000 Subject: fix: restore landing visibility without blocking lazy loads --- src/lib/Landing.svelte | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/lib/Landing.svelte b/src/lib/Landing.svelte index 604becee..9c76ef04 100644 --- a/src/lib/Landing.svelte +++ b/src/lib/Landing.svelte @@ -4,7 +4,7 @@ import { env } from "$env/dynamic/public"; import localforage from "localforage"; import { onMount } from "svelte"; -let sectionsVisible = $state([false, false, false]); +let sectionsLoaded = $state([false, false, false]); let mangaContainer: HTMLElement; let animeContainer: HTMLElement; let gridLimit = $state(undefined); @@ -56,13 +56,35 @@ const calculateLimit = () => { }; onMount(() => { + if (!("IntersectionObserver" in window)) { + sectionsLoaded = [true, true, true]; + + calculateLimit(); + + const resizeObserver = new ResizeObserver(calculateLimit); + + if (mangaContainer) resizeObserver.observe(mangaContainer); + if (animeContainer) resizeObserver.observe(animeContainer); + + const handleKeydown = (e: KeyboardEvent) => { + if (e.key === "Escape" && demoFocused) demoFocused = false; + }; + + document.addEventListener("keydown", handleKeydown); + + return () => { + resizeObserver.disconnect(); + document.removeEventListener("keydown", handleKeydown); + }; + } + const intersectionObserver = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { const index = Number(entry.target.getAttribute("data-section")); - sectionsVisible[index] = true; + sectionsLoaded[index] = true; } }); }, @@ -94,16 +116,16 @@ onMount(() => { }); $effect(() => { - if (sectionsVisible[0]) loadMangaDemo(); + if (sectionsLoaded[0]) loadMangaDemo(); }); $effect(() => { - if (sectionsVisible[1]) loadAnimeDemo(); + if (sectionsLoaded[1]) loadAnimeDemo(); });
-
+
{#if MangaDemoComponent} @@ -128,7 +150,7 @@ $effect(() => {
-
+