misc: update virtual list overscan logic
This commit is contained in:
5 files changed
+13
-7
No files matched your search
@@ -9,7 +9,6 @@
|
||||
import { Badge } from 'mono-svelte'
|
||||
import { Icon, ServerStack } from 'svelte-hero-icons'
|
||||
import Link from '../input/Link.svelte'
|
||||
import Entity from '../ui/Entity.svelte'
|
||||
import Expandable from '../ui/Expandable.svelte'
|
||||
import LabelStat from '../ui/LabelStat.svelte'
|
||||
import ItemList from './generic/ItemList.svelte'
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
{#if offsetEl}
|
||||
<VirtualList
|
||||
class="divide-y divide-slate-200 dark:divide-zinc-800 w-full"
|
||||
overscan={1000}
|
||||
estimatedHeight={300}
|
||||
overscan={2}
|
||||
estimatedHeight={2000}
|
||||
items={nodes}
|
||||
{initialOffset}
|
||||
>
|
||||
|
||||
@@ -174,7 +174,8 @@
|
||||
class="divide-y -mx-4 sm:-mx-6 divide-slate-200 dark:divide-zinc-900"
|
||||
items={posts}
|
||||
{initialOffset}
|
||||
overscan={1000}
|
||||
overscan={3}
|
||||
estimatedHeight={settings.view == 'cozy' ? 500 : 150}
|
||||
bind:restore={postFeeds.value[feedId].clientData}
|
||||
bind:this={listComp}
|
||||
>
|
||||
|
||||
@@ -112,13 +112,19 @@
|
||||
|
||||
const firstIndex = findFirstVisibleIndex(scrollTop, cumulativeItemHeights)
|
||||
|
||||
let i = firstIndex
|
||||
const startIndex = Math.max(0, firstIndex - overscan)
|
||||
|
||||
let i = startIndex
|
||||
let offset = i == 0 ? 0 : cumulativeItemHeights[i - 1]
|
||||
|
||||
while (i < items.length && offset < scrollTop + viewportHeight + overscan) {
|
||||
while (i < items.length) {
|
||||
newVisibleItems.push({ index: i, offset: offset })
|
||||
const height = itemHeights[i] || estimatedHeight
|
||||
offset += height
|
||||
|
||||
if (offset > scrollTop + viewportHeight + overscan * estimatedHeight)
|
||||
break
|
||||
|
||||
i++
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<CommentForm
|
||||
postId={post.post_view.post.id}
|
||||
oncomment={comment => {
|
||||
comments.comments = [comment.comment_view, ...comments.comments]
|
||||
comments.comments.push(comment.comment_view)
|
||||
}}
|
||||
onfocus={() => (commenting = true)}
|
||||
tools={commenting}
|
||||
|
||||
Reference in new issue
Block a user