Only 'jumps' if comment above the top. Also decreases offset at the top

remotes/1693045480750635534/spooky-22
Yo Mama 2021-09-19 15:50:20 +02:00
parent bed7ec1069
commit ec96d0d685
1 changed files with 4 additions and 7 deletions

View File

@ -81,17 +81,14 @@
// Toggle comment collapse
function collapse_comment(comment_id) {
const OFFSET = window.innerHeight / 3
const comment = "comment-" + comment_id;
const comment = "comment-" + comment_id
const element = document.getElementById(comment)
const closed = element.classList.toggle("collapsed");
const closed = element.classList.toggle("collapsed")
const top = element.getBoundingClientRect().y
if (closed && top < OFFSET) {
if (closed && top < 0) {
element.scrollIntoView()
window.scrollBy(0, - OFFSET)
window.scrollBy(0, - 100)
}
};