From 8d05a7946460ce906f2ba71b87b98d272aea3867 Mon Sep 17 00:00:00 2001 From: kek7198 Date: Thu, 9 Dec 2021 16:33:19 -0600 Subject: [PATCH] fix --- files/assets/js/comments.js | 11 +++++------ files/templates/comments.html | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/files/assets/js/comments.js b/files/assets/js/comments.js index 1bccb6174..2886d3b29 100644 --- a/files/assets/js/comments.js +++ b/files/assets/js/comments.js @@ -4,10 +4,9 @@ function timestamp(str, ti) { }; function collapse_comment(comment_id) { - const comment = "comment-" + comment_id - const element = document.getElementById(comment) - const closed = element.classList.toggle("collapsed") - const top = element.getBoundingClientRect().y + const comment = `comment-${comment_id}`; + const closed = comment.classList.toggle("collapsed"); + const top = comment.getBoundingClientRect().y; const text = document.getElementById(`comment-text-${comment_id}`) const actions = document.getElementById(`comment-${comment_id}-actions`) @@ -16,10 +15,10 @@ function collapse_comment(comment_id) { const arr = [text, actions, repliesOf]; arr.map(x => x.classList.toggle('hidden')); // hide comment elements - comment.classList.toggle('items-center opacity-50') // apply flex alignment and opacity to comment parent wrapping div + comment.classList.toggle('items-center opacity-50'); // apply flex alignment and opacity to comment parent wrapping div if (closed && top < 0) { - element.scrollIntoView() + comment.scrollIntoView() window.scrollBy(0, - 100) } }; \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index f472a7d4c..c381615d8 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -37,7 +37,7 @@ {% endif %} - + {% include "expanded_image_modal.html" %}