Add highlight to the element specified in the anchor

This commit is contained in:
Visman 2023-07-02 13:45:41 +07:00
parent a9ef39c152
commit 4f0c9c639f
2 changed files with 35 additions and 1 deletions

View file

@ -5,7 +5,9 @@ if (typeof ForkBB === "undefined" || !ForkBB) {
ForkBB.common = (function (doc, win) {
'use strict';
var selectorBack = ".f-go-back";
var selectorBack = ".f-go-back",
hlClass = "f-highlighted";
function initGoBack()
{
@ -20,9 +22,24 @@ ForkBB.common = (function (doc, win) {
}
}
function initAnchorHL()
{
var target,
hash = (win.location.hash || "").replace(/^#/, "");
if (hash && (target = doc.getElementById(hash))) {
target.classList.add(hlClass);
setTimeout(function() {
target.classList.remove(hlClass);
}, 1500);
}
}
return {
init : function () {
initGoBack();
initAnchorHL();
},
};
}(document, window));

View file

@ -2925,3 +2925,20 @@ body,
color: #ffffff;
background-color: #4285f4;
}
/************/
/* Анимация */
/************/
#fork .f-highlighted,
#fork .f-highlighted .f-post-body {
animation: highlightedAnim 0.5s linear 0s 2 normal none;
}
@keyframes highlightedAnim {
0%, 100% {
box-shadow: 0 0 0 0 transparent inset;
}
50% {
box-shadow: 0 0 0 0.25rem #AA7939 inset;
}
}