|
1 | 1 | <script>
|
2 | 2 | import { base } from '$app/paths';
|
3 | 3 | import FassungenContent from './FassungenContent.svelte';
|
| 4 | + import { SlideToggle } from '@skeletonlabs/skeleton'; |
4 | 5 |
|
5 | 6 | /** @type {{data: import('./$types').PageData}} */
|
6 | 7 | let { data } = $props();
|
|
15 | 16 | thirties = [];
|
16 | 17 |
|
17 | 18 | fetchPage = async (/** @type {string} */ page) => {
|
18 |
| - // console.log('fetching', page); |
19 |
| - // console.log(Number(page), !this.thirties.length); |
20 | 19 | if (!this.thirties.length) {
|
21 | 20 | let [d, m, G, T] = await fetch(`${base}/fassungen/data/${Number(page) - 1}`).then((r) =>
|
22 | 21 | r.json()
|
|
70 | 69 | $effect(() => {
|
71 | 70 | localPages.fetchPage(data.thirties);
|
72 | 71 | });
|
| 72 | + let scrolltop = $state(0); |
| 73 | + let synchro = $state(true); |
73 | 74 | </script>
|
74 | 75 |
|
75 | 76 | <section class="w-full">
|
76 | 77 | <h1 class="h1 my-4">Fassungsansicht</h1>
|
77 | 78 | <div class="grid gap-6 md:grid-cols-2 md:my-8">
|
78 | 79 | <p>Einstellungen und Links zu den Textzeugen.</p>
|
| 80 | + <SlideToggle active="bg-primary-500" name="synchro" bind:checked={synchro}> |
| 81 | + Synchrones scrollen |
| 82 | + </SlideToggle> |
79 | 83 | </div>
|
80 | 84 | <div
|
81 | 85 | class="grid grid-cols-[repeat(auto-fit,minmax(400px,1fr))] gap-4 bg-surface-active-token my-4 py-4 px-8 rounded-xl"
|
82 | 86 | >
|
83 | 87 | {#each localPages.pages as pages}
|
84 | 88 | {#if pages.length >= 3}
|
85 | 89 | <!-- when at least 3 pages are loaded, the one for the currect thirties should be loaded aswell -->
|
86 |
| - <FassungenContent {pages} /> |
| 90 | + {#if synchro} |
| 91 | + <FassungenContent {pages} bind:scrolltop /> |
| 92 | + {:else} |
| 93 | + <FassungenContent {pages} /> |
| 94 | + {/if} |
87 | 95 | {/if}
|
88 | 96 | {/each}
|
89 | 97 | </div>
|
|
0 commit comments