diff options
author | Wolfgang Müller | 2025-02-13 18:22:51 +0100 |
---|---|---|
committer | Wolfgang Müller | 2025-02-13 18:22:51 +0100 |
commit | 341fc19d4b7e9d8fb8b9a9d72377cf36565f2f2e (patch) | |
tree | f29c4f00e7a1766d4c8bbf6eff29202efb918cab /frontend/src/lib | |
parent | 6b55cf86c40cab959be942caa642d67cc1b45668 (diff) | |
download | hircine-341fc19d4b7e9d8fb8b9a9d72377cf36565f2f2e.tar.gz |
frontend: Increase lookaround when preloading page images
Instead of preloading one image in next and previous direction, preload
two.
Diffstat (limited to 'frontend/src/lib')
-rw-r--r-- | frontend/src/lib/reader/PageView.svelte | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/frontend/src/lib/reader/PageView.svelte b/frontend/src/lib/reader/PageView.svelte index 81fbb97..fc45cfa 100644 --- a/frontend/src/lib/reader/PageView.svelte +++ b/frontend/src/lib/reader/PageView.svelte @@ -23,19 +23,24 @@ } function pagesAround(around: number) { - const peek = (at: number) => { - if (at < 0 || at >= chunks.length) return []; + const pages: PageFragment[] = []; - const pages: PageFragment[] = [chunks[at].main]; + const push = (at: number) => { + if (at < 0 || at >= chunks.length) return; + + pages.push(chunks[at].main); if (chunks[at].secondary) { pages.push(chunks[at].secondary); } - - return pages; }; - return [...peek(lookup[around] + 1), ...peek(lookup[around] - 1)]; + for (let i = 1; i <= 2; i++) { + push(lookup[around] + i); + push(lookup[around] - i); + } + + return pages; } const next = () => gotoChunk(lookup[reader.page] + 1); |