forked from tildeverse/tilde.news
Feature: scroll to unread comments (#1156)
This commit is contained in:
parent
7c999c37c8
commit
3d14ca7723
|
@ -728,4 +728,12 @@ onPageLoad(() => {
|
|||
response.text().then(text => replace(comment, text));
|
||||
});
|
||||
});
|
||||
|
||||
on('click', '.comment_unread', (event) => {
|
||||
const nodes = document.getElementsByClassName('comment_unread')
|
||||
const foundIndex = Array.from(nodes).findIndex(node => node === event.target)
|
||||
const targetIndex = (foundIndex + 1) % nodes.length;
|
||||
const targetY = nodes[targetIndex].getBoundingClientRect().top + window.scrollY
|
||||
window.scrollTo({ top: targetY, behavior: 'smooth' })
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1176,6 +1176,7 @@ div.comment_form_container textarea {
|
|||
span.comment_unread {
|
||||
color: var(--color-fg-accent);
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* trees */
|
||||
|
|
Loading…
Reference in New Issue