fix: update posts length
This commit is contained in:
1 parent
58b6c12a8b
commit
86f4bec26d
1 file changed
+8
-19
@@ -69,32 +69,20 @@
|
||||
return results
|
||||
}
|
||||
|
||||
$: combinedPosts = combineCrossposts(posts)
|
||||
// $: combinedPosts = combineCrossposts(posts)
|
||||
|
||||
let viewPost: number = -1
|
||||
|
||||
let list: any
|
||||
|
||||
function calculateHeight(index: number): number {
|
||||
if (browser) {
|
||||
const el = document.querySelector(`[data-index="${index}"]`)
|
||||
return el?.clientHeight ?? 150
|
||||
} else return 150
|
||||
|
||||
return 150
|
||||
}
|
||||
|
||||
afterUpdate(() => {
|
||||
setTimeout(() => {
|
||||
list?.recomputeSizes?.(0)
|
||||
})
|
||||
})
|
||||
|
||||
const virtualizer = createWindowVirtualizer({
|
||||
count: posts.length,
|
||||
estimateSize: () => 150,
|
||||
})
|
||||
|
||||
$: if (posts.length)
|
||||
$virtualizer.setOptions({
|
||||
count: posts.length,
|
||||
})
|
||||
|
||||
let virtualItemEls: HTMLElement[] = []
|
||||
|
||||
$: items = $virtualizer.getVirtualItems()
|
||||
@@ -140,6 +128,7 @@
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items[0]
|
||||
? items[0].start
|
||||
: 0}px);"
|
||||
class="divide-y divide-slate-200 dark:divide-zinc-800"
|
||||
>
|
||||
{#each items as row, index (row.index)}
|
||||
<li
|
||||
@@ -147,7 +136,7 @@
|
||||
y: -8,
|
||||
duration: 500,
|
||||
opacity: 0,
|
||||
delay: 200,
|
||||
delay: 100 + index * 20,
|
||||
}}
|
||||
bind:this={virtualItemEls[index]}
|
||||
data-index={row.index}
|
||||
|
||||
Reference in new issue
Block a user