1
0
mirror of https://github.com/suk-ws/ph-Bookshelf.git synced 2025-01-31 21:13:00 +08:00
ph-Bookshelf/assets/web/bread-card-markdown-heading-permalink-highlight.js
2023-03-03 21:40:17 +08:00

36 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************
##############################################################################
##### #####
##### JavaScript of ph-Bookshelf of ui design BreadCard #####
##### enhanced extension #####
##### for ! Permalink Highlight ! #####
##### for ¶[Heading Permalink](#heading-permalink) #####
##### #####
##### @author: Sukazyo Workshop #####
##### @version 1.0 #####
##### #####
##############################################################################
******************************************************************************/
const headingPermalink_animaTimeoutMs = 150;
function headingPermalink_onScrollFocused (event) {
const node = event.target;
node.classList.add("highlighting");
sleep(headingPermalink_animaTimeoutMs).then(() => {
node.classList.remove("highlighting");
sleep(headingPermalink_animaTimeoutMs).then(() => {
node.classList.add("highlighting");
sleep(headingPermalink_animaTimeoutMs).then(() => {
node.classList.remove("highlighting");
});
});
});
}
for (const node of document.getElementsByClassName("heading-permalink")) {
node.addEventListener("focus", headingPermalink_onScrollFocused);
}
// document.getElementById("main").addEventListener("scrollend", onHeadingPermalinkScrollFocused);