fix: move comment jumping to onMount
This commit is contained in:
1 parent
018647b41b
commit
1e8958471f
1 file changed
+3
-4
@@ -19,6 +19,7 @@
|
|||||||
import { afterNavigate } from '$app/navigation'
|
import { afterNavigate } from '$app/navigation'
|
||||||
import { backOut } from 'svelte/easing'
|
import { backOut } from 'svelte/easing'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
import { browser } from '$app/environment'
|
||||||
|
|
||||||
export let nodes: CommentNodeI[]
|
export let nodes: CommentNodeI[]
|
||||||
export let isParent: boolean
|
export let isParent: boolean
|
||||||
@@ -28,9 +29,7 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
hydrated = true
|
hydrated = true
|
||||||
})
|
if (isParent && $page.url.hash && browser) {
|
||||||
afterNavigate(() => {
|
|
||||||
if (isParent && $page.url.hash) {
|
|
||||||
document.getElementById($page.url.hash)?.scrollIntoView({
|
document.getElementById($page.url.hash)?.scrollIntoView({
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
block: 'center',
|
block: 'center',
|
||||||
@@ -74,7 +73,7 @@
|
|||||||
// 0.18.2 -> 0.18.3 broke this
|
// 0.18.2 -> 0.18.3 broke this
|
||||||
// so i'm adding this check
|
// so i'm adding this check
|
||||||
const treeParent = tree.find(
|
const treeParent = tree.find(
|
||||||
(c) => c.comment_view.comment.id == parent.comment_view.comment.id
|
(c) => c.comment_view.comment.id == parent.comment_view.comment.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (treeParent) {
|
if (treeParent) {
|
||||||
|
|||||||
Reference in new issue
Block a user