fix: failed scrolling with comment jumping
This commit is contained in:
6 files changed
+34
-31
No files matched your search
@@ -18,8 +18,7 @@
|
||||
class="flex flex-col gap-4 my-auto h-full justify-center max-w-md w-full mx-auto"
|
||||
>
|
||||
<h1
|
||||
class="text-primary-900 dark:text-primary-100 text-6xl font-black flex items-center flex-row gap-2
|
||||
font-display border-b pb-4 border-slate-200 dark:border-zinc-800"
|
||||
class="text-primary-900 dark:text-primary-100 text-6xl font-black flex items-center flex-row gap-2 border-b pb-4 border-slate-200 dark:border-zinc-800 font-mono"
|
||||
>
|
||||
{page.status}
|
||||
</h1>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { browser } from '$app/environment'
|
||||
import { page } from '$app/state'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
||||
import CommentListVirtualizer from '$lib/components/lemmy/comment/CommentListVirtualizer.svelte'
|
||||
@@ -13,6 +15,7 @@
|
||||
GetPostResponse,
|
||||
} from 'lemmy-js-client'
|
||||
import { Button, Option, Select } from 'mono-svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import {
|
||||
ArrowPath,
|
||||
ArrowTrendingDown,
|
||||
@@ -49,6 +52,16 @@
|
||||
$effect(() => {
|
||||
tree = buildCommentsTree(comments.comments)
|
||||
})
|
||||
|
||||
onMount(() => {
|
||||
if (browser && page.url.hash)
|
||||
// hack because virtual list needs to calc heights
|
||||
setTimeout(() => {
|
||||
document
|
||||
.getElementById(page.url.hash.slice(1))
|
||||
?.scrollIntoView({ behavior: 'instant', block: 'center' })
|
||||
}, 100)
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if profile.current?.jwt}
|
||||
@@ -154,7 +167,7 @@
|
||||
{:else}
|
||||
<div class="divide-y divide-slate-200 dark:divide-zinc-800">
|
||||
<div class="-mx-4 sm:-mx-6 px-4 sm:px-6">
|
||||
<Comments isParent={true} nodes={tree} post={post.post_view.post} />
|
||||
<Comments nodes={tree} post={post.post_view.post} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
Reference in new issue
Block a user