Fixes anchored post links spamming the browser history.
This commit is contained in:
parent
5cc405ad69
commit
21a75483fe
2 changed files with 8 additions and 6 deletions
|
|
@ -266,7 +266,7 @@ $threads-meta-color: #545d70;
|
||||||
border-top: 1px solid $border-color;
|
border-top: 1px solid $border-color;
|
||||||
padding-top: $control-padding-y-lg;
|
padding-top: $control-padding-y-lg;
|
||||||
|
|
||||||
&:target .post-main {
|
&:target .post-main, &.highlight .post-main {
|
||||||
animation: highlight 2000ms ease-out;
|
animation: highlight 2000ms ease-out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,7 @@ when defined(js):
|
||||||
() => (
|
() => (
|
||||||
# Would have used scrollIntoView but then the `:target` selector
|
# Would have used scrollIntoView but then the `:target` selector
|
||||||
# isn't activated.
|
# isn't activated.
|
||||||
window.location.hash = "";
|
getVNodeById($postId.get()).dom.scrollIntoView()
|
||||||
window.location.hash = "#" & $postId.get()
|
|
||||||
),
|
),
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
|
|
@ -214,11 +213,13 @@ when defined(js):
|
||||||
italic(class="fas fa-reply")
|
italic(class="fas fa-reply")
|
||||||
text " Reply"
|
text " Reply"
|
||||||
|
|
||||||
proc genPost(post: Post, thread: Thread, currentUser: Option[User]): VNode =
|
proc genPost(
|
||||||
|
post: Post, thread: Thread, currentUser: Option[User], highlight: bool
|
||||||
|
): VNode =
|
||||||
let postCopy = post # TODO: Another workaround here, closure capture :(
|
let postCopy = post # TODO: Another workaround here, closure capture :(
|
||||||
|
|
||||||
result = buildHtml():
|
result = buildHtml():
|
||||||
tdiv(class="post", id = $post.id):
|
tdiv(class=class({"highlight": highlight}, "post"), id = $post.id):
|
||||||
tdiv(class="post-icon"):
|
tdiv(class="post-icon"):
|
||||||
render(post.author, "post-avatar")
|
render(post.author, "post-avatar")
|
||||||
tdiv(class="post-main"):
|
tdiv(class="post-main"):
|
||||||
|
|
@ -345,7 +346,8 @@ when defined(js):
|
||||||
genTimePassed(prevPost.get(), some(post), false)
|
genTimePassed(prevPost.get(), some(post), false)
|
||||||
if post.moreBefore.len > 0:
|
if post.moreBefore.len > 0:
|
||||||
genLoadMore(post, i)
|
genLoadMore(post, i)
|
||||||
genPost(post, list.thread, currentUser)
|
let highlight = postId.isSome() and postId.get() == post.id
|
||||||
|
genPost(post, list.thread, currentUser, highlight)
|
||||||
prevPost = some(post)
|
prevPost = some(post)
|
||||||
|
|
||||||
if prevPost.isSome:
|
if prevPost.isSome:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue