misc: tweak virtualization
This commit is contained in:
4 files changed
+27
-22
No files matched your search
@@ -2,8 +2,9 @@
|
||||
import type { Post } from 'lemmy-js-client'
|
||||
import type { CommentNodeI } from './comments.svelte'
|
||||
import Comments from './Comments.svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import { onMount, tick } from 'svelte'
|
||||
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
||||
import { page } from '$app/state'
|
||||
|
||||
interface Props {
|
||||
nodes: CommentNodeI[]
|
||||
@@ -14,6 +15,7 @@
|
||||
let { nodes, post, scrollTo }: Props = $props()
|
||||
|
||||
let offsetEl = $state<HTMLElement>()
|
||||
let list = $state()
|
||||
|
||||
let initialOffset = $state(0)
|
||||
|
||||
@@ -55,6 +57,7 @@
|
||||
overscan={500}
|
||||
items={nodes}
|
||||
{initialOffset}
|
||||
bind:this={list}
|
||||
>
|
||||
{#snippet item(item, index)}
|
||||
<div class="-mx-4 sm:-mx-6 px-4 sm:px-6">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { debounce } from 'mono-svelte/util/time'
|
||||
import { onDestroy, tick, untrack, type Snippet } from 'svelte'
|
||||
import type { HTMLAttributes } from 'svelte/elements'
|
||||
import { innerHeight } from 'svelte/reactivity/window'
|
||||
import { innerHeight, scrollY } from 'svelte/reactivity/window'
|
||||
|
||||
interface Props extends HTMLAttributes<HTMLDivElement> {
|
||||
items: T[]
|
||||
|
||||
@@ -206,25 +206,27 @@
|
||||
<div
|
||||
class="flex flex-col mt-4 divide-slate-200 dark:divide-zinc-800 !divide-y"
|
||||
>
|
||||
{#each data.results.value as result}
|
||||
{#if isPostView(result)}
|
||||
<Post post={result} />
|
||||
{:else if isCommentView(result)}
|
||||
<CommentItem comment={result} />
|
||||
{:else if isCommunityView(result)}
|
||||
<div
|
||||
class="-mx-4 sm:-mx-6 px-6 hover:bg-slate-100 hover:dark:bg-zinc-800 transition-colors"
|
||||
>
|
||||
<CommunityItem community={result} showCounts={false} class="py-3" />
|
||||
</div>
|
||||
{:else if isUser(result)}
|
||||
<div
|
||||
class="-mx-4 sm:-mx-6 px-6 hover:bg-slate-100 hover:dark:bg-zinc-800 transition-colors"
|
||||
>
|
||||
<UserItem user={result} showCounts={false} class="py-3" />
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{#key data.results.value}
|
||||
{#each data.results.value as result}
|
||||
{#if isPostView(result)}
|
||||
<Post post={result} />
|
||||
{:else if isCommentView(result)}
|
||||
<CommentItem comment={result} />
|
||||
{:else if isCommunityView(result)}
|
||||
<div
|
||||
class="-mx-4 sm:-mx-6 px-6 hover:bg-slate-100 hover:dark:bg-zinc-800 transition-colors"
|
||||
>
|
||||
<CommunityItem community={result} showCounts={false} class="py-3" />
|
||||
</div>
|
||||
{:else if isUser(result)}
|
||||
<div
|
||||
class="-mx-4 sm:-mx-6 px-6 hover:bg-slate-100 hover:dark:bg-zinc-800 transition-colors"
|
||||
>
|
||||
<UserItem user={result} showCounts={false} class="py-3" />
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{/key}
|
||||
</div>
|
||||
<div class="mt-4"></div>
|
||||
{#if data.results.value.length > 0}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { client, getClient } from '$lib/lemmy.svelte.js'
|
||||
import { getItemPublished } from '$lib/lemmy/item.js'
|
||||
import { getItemPublished, isPostView } from '$lib/lemmy/item.js'
|
||||
import { ReactiveState } from '$lib/promise.svelte.js'
|
||||
import type {
|
||||
CommentView,
|
||||
|
||||
Reference in new issue
Block a user