tempfix: await tick, virtualizer measure

This commit is contained in:
Xylight committed 2024-07-19 20:32:48 -07:00
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>
-20
View File
@@ -2,22 +2,6 @@
@tailwind components;
@tailwind utilities;
@layer utilities {
/*
Chromium browsers don't render nested backdrop filters.
As a workaround, add 'before:' to the outer filter, along with 'before:backdrop-hack':
<div class="before:backdrop-blur-md before:backdrop-hack>
<div class="backdrop-blur-md"></div>
</div>
See https://stackoverflow.com/a/76207141.
*/
.backdrop-hack {
@apply absolute inset-0 -z-10;
}
}
@font-face {
font-family: 'Inter';
src: url('/font/Inter.woff2') format('woff2');
@@ -105,7 +89,3 @@ pre {
.dark ::-webkit-scrollbar-thumb {
@apply bg-zinc-800;
}
.banner {
mask-image: linear-gradient(to left, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
}