Feature: scroll to unread comments (#1156)

This commit is contained in:
John Pash 2023-03-03 02:36:56 +00:00 committed by GitHub
parent 7c999c37c8
commit 3d14ca7723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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' })
});
});

View File

@ -1176,6 +1176,7 @@ div.comment_form_container textarea {
span.comment_unread {
color: var(--color-fg-accent);
font-weight: 600;
cursor: pointer;
}
/* trees */