aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Landing.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Landing.svelte')
-rw-r--r--src/lib/Landing.svelte78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/lib/Landing.svelte b/src/lib/Landing.svelte
index 51167432..dd493be4 100644
--- a/src/lib/Landing.svelte
+++ b/src/lib/Landing.svelte
@@ -1,10 +1,10 @@
<script lang="ts">
-import root from './Utility/root';
-import { env } from '$env/dynamic/public';
-import CompletedAnimeList from './List/Anime/CompletedAnimeList.svelte';
-import MangaListTemplate from './List/Manga/MangaListTemplate.svelte';
-import localforage from 'localforage';
-import { onMount } from 'svelte';
+import root from "./Utility/root";
+import { env } from "$env/dynamic/public";
+import CompletedAnimeList from "./List/Anime/CompletedAnimeList.svelte";
+import MangaListTemplate from "./List/Manga/MangaListTemplate.svelte";
+import localforage from "localforage";
+import { onMount } from "svelte";
let sectionsVisible = $state<boolean[]>([false, false, false]);
let mangaContainer: HTMLElement;
@@ -16,53 +16,53 @@ const COVER_GAP = 12;
const dummyCount = 20;
const calculateLimit = () => {
- const container = mangaContainer || animeContainer;
+ const container = mangaContainer || animeContainer;
- if (!container) return;
+ if (!container) return;
- const containerWidth = container.clientWidth;
- const itemWidth = COVER_WIDTH + COVER_GAP;
- const padding = containerWidth < 500 ? 48 : 36;
+ const containerWidth = container.clientWidth;
+ const itemWidth = COVER_WIDTH + COVER_GAP;
+ const padding = containerWidth < 500 ? 48 : 36;
- gridLimit = Math.max(2, Math.floor((containerWidth - padding) / itemWidth));
+ gridLimit = Math.max(2, Math.floor((containerWidth - padding) / itemWidth));
};
onMount(() => {
- const intersectionObserver = new IntersectionObserver(
- (entries) => {
- entries.forEach((entry) => {
- if (entry.isIntersecting) {
- const index = Number(entry.target.getAttribute('data-section'));
+ const intersectionObserver = new IntersectionObserver(
+ (entries) => {
+ entries.forEach((entry) => {
+ if (entry.isIntersecting) {
+ const index = Number(entry.target.getAttribute("data-section"));
- sectionsVisible[index] = true;
- }
- });
- },
- { threshold: 0.1 }
- );
+ sectionsVisible[index] = true;
+ }
+ });
+ },
+ { threshold: 0.1 },
+ );
- document.querySelectorAll('.landing-section').forEach((el) => {
- intersectionObserver.observe(el);
- });
+ document.querySelectorAll(".landing-section").forEach((el) => {
+ intersectionObserver.observe(el);
+ });
- calculateLimit();
+ calculateLimit();
- const resizeObserver = new ResizeObserver(calculateLimit);
+ const resizeObserver = new ResizeObserver(calculateLimit);
- if (mangaContainer) resizeObserver.observe(mangaContainer);
- if (animeContainer) resizeObserver.observe(animeContainer);
+ if (mangaContainer) resizeObserver.observe(mangaContainer);
+ if (animeContainer) resizeObserver.observe(animeContainer);
- const handleKeydown = (e: KeyboardEvent) => {
- if (e.key === 'Escape' && demoFocused) demoFocused = false;
- };
+ const handleKeydown = (e: KeyboardEvent) => {
+ if (e.key === "Escape" && demoFocused) demoFocused = false;
+ };
- document.addEventListener('keydown', handleKeydown);
+ document.addEventListener("keydown", handleKeydown);
- return () => {
- intersectionObserver.disconnect();
- resizeObserver.disconnect();
- document.removeEventListener('keydown', handleKeydown);
- };
+ return () => {
+ intersectionObserver.disconnect();
+ resizeObserver.disconnect();
+ document.removeEventListener("keydown", handleKeydown);
+ };
});
</script>