tempfix: await tick, virtualizer measure
This commit is contained in:
1 parent
25303be2fe
commit
f420ced79c
2 files changed
+27
-28
No files matched your search
@@ -47,8 +47,6 @@
|
||||
const virtualizer = createWindowVirtualizer({
|
||||
count: posts.length,
|
||||
estimateSize: () => 150,
|
||||
// @ts-ignore
|
||||
scrollMargin: virtualListEl?.offsetTop ?? 0,
|
||||
})
|
||||
|
||||
$: items = $virtualizer.getVirtualItems()
|
||||
@@ -57,10 +55,11 @@
|
||||
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
||||
}
|
||||
|
||||
$: $virtualizer.setOptions({
|
||||
scrollMargin: virtualListEl?.offsetTop ?? 0,
|
||||
count: posts.length,
|
||||
})
|
||||
$: if (posts.length && virtualListEl)
|
||||
$virtualizer.setOptions({
|
||||
scrollMargin: virtualListEl?.offsetTop,
|
||||
count: posts.length,
|
||||
})
|
||||
|
||||
afterNavigate(() => {
|
||||
console.log($postFeeds[feedId].lastSeen)
|
||||
@@ -170,6 +169,11 @@
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
onMount(async () => {
|
||||
await tick()
|
||||
$virtualizer.measure()
|
||||
})
|
||||
</script>
|
||||
|
||||
<ul
|
||||
@@ -184,7 +188,6 @@
|
||||
'embed embed'
|
||||
'actions actions'; --template-columns: auto 1fr;`
|
||||
: ``}
|
||||
bind:this={virtualListEl}
|
||||
>
|
||||
{#if posts?.length == 0}
|
||||
<div class="h-full grid place-items-center">
|
||||
@@ -204,6 +207,7 @@
|
||||
style="position:relative; height: {browser
|
||||
? `${$virtualizer.getTotalSize()}px`
|
||||
: '100%'}; width: 100%;"
|
||||
bind:this={virtualListEl}
|
||||
>
|
||||
<div
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items?.[0]
|
||||
@@ -216,7 +220,7 @@
|
||||
<li
|
||||
bind:this={virtualItemEls[index]}
|
||||
data-index={row.index}
|
||||
class="relative post-container"
|
||||
class="relative post-container pop-in"
|
||||
>
|
||||
{#if posts[row.index]}
|
||||
<Post
|
||||
@@ -278,4 +282,19 @@
|
||||
.skeleton * {
|
||||
@apply bg-slate-100 dark:bg-zinc-800 rounded-md;
|
||||
}
|
||||
|
||||
@keyframes popIn {
|
||||
from {
|
||||
transform: translateY(-24px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0px);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.pop-in {
|
||||
animation: popIn 500ms cubic-bezier(0.075, 0.82, 0.165, 1) forwards;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user