From 88d4f8afcf27b7c8abe9e3720df46f7288617b63 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Sat, 2 Mar 2019 15:16:56 -0500 Subject: [PATCH] commento.js: use scrollIntoView for #commento --- frontend/js/commento.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/js/commento.js b/frontend/js/commento.js index 5537d11..aabc9b0 100644 --- a/frontend/js/commento.js +++ b/frontend/js/commento.js @@ -1610,14 +1610,18 @@ function loadHash() { - if (window.location.hash && window.location.hash.startsWith("#commento-")) { - var el = $(ID_CARD + window.location.hash.split("-")[1]); - if (el === null) { - return; - } + if (window.location.hash) { + if (window.location.hash.startsWith("#commento-")) { + var el = $(ID_CARD + window.location.hash.split("-")[1]); + if (el === null) { + return; + } - classAdd(el, "highlighted-card"); - el.scrollIntoView(true); + classAdd(el, "highlighted-card"); + el.scrollIntoView(true); + } else if (window.location.hash.startsWith("#commento")) { + root.scrollIntoView(true); + } } }