forked from rDrama/rDrama
1
0
Fork 0

Merge pull request #40 from yoMamasDic/master

Improve comment collapse
master
Aevann1 2021-09-15 03:12:40 +02:00 committed by GitHub
commit edfba68272
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