forked from rDrama/rDrama
1
0
Fork 0

Improve comment collapse

master
Yo Mama 2021-09-15 00:39:45 +02:00
parent b7e99aa288
commit c27f644417
1 changed files with 9 additions and 2 deletions

View File

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