From ec96d0d685ac9f49088155b76cda060ce48c5f48 Mon Sep 17 00:00:00 2001 From: Yo Mama Date: Sun, 19 Sep 2021 15:50:20 +0200 Subject: [PATCH] Only 'jumps' if comment above the top. Also decreases offset at the top --- files/templates/default.html | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/files/templates/default.html b/files/templates/default.html index 3a9ef1f99f..5fc9eb789c 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -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) } };