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({
|
const virtualizer = createWindowVirtualizer({
|
||||||
count: posts.length,
|
count: posts.length,
|
||||||
estimateSize: () => 150,
|
estimateSize: () => 150,
|
||||||
// @ts-ignore
|
|
||||||
scrollMargin: virtualListEl?.offsetTop ?? 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$: items = $virtualizer.getVirtualItems()
|
$: items = $virtualizer.getVirtualItems()
|
||||||
@@ -57,10 +55,11 @@
|
|||||||
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
||||||
}
|
}
|
||||||
|
|
||||||
$: $virtualizer.setOptions({
|
$: if (posts.length && virtualListEl)
|
||||||
scrollMargin: virtualListEl?.offsetTop ?? 0,
|
$virtualizer.setOptions({
|
||||||
count: posts.length,
|
scrollMargin: virtualListEl?.offsetTop,
|
||||||
})
|
count: posts.length,
|
||||||
|
})
|
||||||
|
|
||||||
afterNavigate(() => {
|
afterNavigate(() => {
|
||||||
console.log($postFeeds[feedId].lastSeen)
|
console.log($postFeeds[feedId].lastSeen)
|
||||||
@@ -170,6 +169,11 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
await tick()
|
||||||
|
$virtualizer.measure()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul
|
<ul
|
||||||
@@ -184,7 +188,6 @@
|
|||||||
'embed embed'
|
'embed embed'
|
||||||
'actions actions'; --template-columns: auto 1fr;`
|
'actions actions'; --template-columns: auto 1fr;`
|
||||||
: ``}
|
: ``}
|
||||||
bind:this={virtualListEl}
|
|
||||||
>
|
>
|
||||||
{#if posts?.length == 0}
|
{#if posts?.length == 0}
|
||||||
<div class="h-full grid place-items-center">
|
<div class="h-full grid place-items-center">
|
||||||
@@ -204,6 +207,7 @@
|
|||||||
style="position:relative; height: {browser
|
style="position:relative; height: {browser
|
||||||
? `${$virtualizer.getTotalSize()}px`
|
? `${$virtualizer.getTotalSize()}px`
|
||||||
: '100%'}; width: 100%;"
|
: '100%'}; width: 100%;"
|
||||||
|
bind:this={virtualListEl}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items?.[0]
|
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items?.[0]
|
||||||
@@ -216,7 +220,7 @@
|
|||||||
<li
|
<li
|
||||||
bind:this={virtualItemEls[index]}
|
bind:this={virtualItemEls[index]}
|
||||||
data-index={row.index}
|
data-index={row.index}
|
||||||
class="relative post-container"
|
class="relative post-container pop-in"
|
||||||
>
|
>
|
||||||
{#if posts[row.index]}
|
{#if posts[row.index]}
|
||||||
<Post
|
<Post
|
||||||
@@ -278,4 +282,19 @@
|
|||||||
.skeleton * {
|
.skeleton * {
|
||||||
@apply bg-slate-100 dark:bg-zinc-800 rounded-md;
|
@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>
|
</style>
|
||||||
@@ -2,22 +2,6 @@
|
|||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@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-face {
|
||||||
font-family: 'Inter';
|
font-family: 'Inter';
|
||||||
src: url('/font/Inter.woff2') format('woff2');
|
src: url('/font/Inter.woff2') format('woff2');
|
||||||
@@ -105,7 +89,3 @@ pre {
|
|||||||
.dark ::-webkit-scrollbar-thumb {
|
.dark ::-webkit-scrollbar-thumb {
|
||||||
@apply bg-zinc-800;
|
@apply bg-zinc-800;
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner {
|
|
||||||
mask-image: linear-gradient(to left, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user