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