From 93daf214e7aa58e2911919eb7859c15fc930d7ed Mon Sep 17 00:00:00 2001 From: Kohei Yoshino Date: Tue, 17 Dec 2024 15:50:55 -0500 Subject: [PATCH] Implement infinite scroll for list items --- .../components/assets/list/asset-list.svelte | 19 +++--- .../components/common/infinite-scroll.svelte | 65 +++++++++++++++++++ src/lib/components/common/listing-grid.svelte | 9 ++- .../contents/list/entry-list.svelte | 21 +++--- .../components/contents/list/file-list.svelte | 10 +-- .../components/search/search-results.svelte | 18 ++--- 6 files changed, 106 insertions(+), 36 deletions(-) create mode 100644 src/lib/components/common/infinite-scroll.svelte diff --git a/src/lib/components/assets/list/asset-list.svelte b/src/lib/components/assets/list/asset-list.svelte index ebbdb936..4f7d4802 100644 --- a/src/lib/components/assets/list/asset-list.svelte +++ b/src/lib/components/assets/list/asset-list.svelte @@ -1,15 +1,16 @@ @@ -28,19 +29,19 @@ {#if Object.values($assetGroups).flat(1).length} {#each Object.entries($assetGroups) as [name, assets] (name)} - {#each assets as asset (asset.path)} - {#key asset.sha} - {#await sleep(0) then} - - {/await} - {/key} - {/each} + + {#snippet renderItem(/** @type {Asset} */ asset)} + {#key asset.sha} + + {/key} + {/snippet} + {/each} diff --git a/src/lib/components/common/infinite-scroll.svelte b/src/lib/components/common/infinite-scroll.svelte new file mode 100644 index 00000000..037e5e21 --- /dev/null +++ b/src/lib/components/common/infinite-scroll.svelte @@ -0,0 +1,65 @@ + + + +{#each items.slice(0, loadedItemSize) as item (item[itemKey])} + {@render renderItem(item)} +{/each} + +{#if loading} +
+{/if} + + diff --git a/src/lib/components/common/listing-grid.svelte b/src/lib/components/common/listing-grid.svelte index 6fd124b8..8e705a9f 100644 --- a/src/lib/components/common/listing-grid.svelte +++ b/src/lib/components/common/listing-grid.svelte @@ -4,6 +4,7 @@ -->
- - - + {#await sleep(0) then} + + + + {/await}