commento.js: add scroll into view based on hash

This commit is contained in:
Adhityaa Chandrasekar 2019-02-17 17:45:05 -05:00
parent a22b49a112
commit 619231e32f
2 changed files with 18 additions and 0 deletions

View File

@ -1523,6 +1523,7 @@
attrSet(footer, "style", ""); attrSet(footer, "style", "");
nameWidthFix(); nameWidthFix();
loadHash();
} }
@ -1570,6 +1571,19 @@
} }
function loadHash() {
if (window.location.hash && window.location.hash.startsWith("#commento-")) {
var el = $(ID_CARD + window.location.hash.split("-")[1]);
if (el === null) {
return;
}
classAdd(el, "highlighted");
el.scrollIntoView(true);
}
}
global.main = function(callback) { global.main = function(callback) {
root = $(ID_ROOT); root = $(ID_ROOT);
if (root === null) { if (root === null) {

View File

@ -55,4 +55,8 @@
font-weight: 700; font-weight: 700;
margin-top: 16px; margin-top: 16px;
} }
.commento-highlighted {
background: $yellow-0;
}
} }