UNPKG

hexo-theme-redefine

Version:

Redefine your writing with Hexo Theme Redefine.

2 lines 830 B
let t=[],e=[],o=!1;const setActiveNavItem=()=>{if(!t.length||!e.length)return;const o=window.scrollY+100;let r=null;e.forEach((t=>{const e=t.offsetTop,n=t.offsetHeight;o>=e&&o<e+n&&(r=t)})),t.forEach((t=>{t.classList.remove("bg-second-background-color"),r&&t.getAttribute("data-category")===r.getAttribute("id")&&t.classList.add("bg-second-background-color")}))},registerScrollHandler=t=>{!o&&t&&(o=!0,window.addEventListener("scroll",((t,e)=>{let o=!1;return(...r)=>{o||(t(...r),o=!0,setTimeout((()=>{o=!1}),e))}})(setActiveNavItem,100),{signal:t}))};export default function initBookmarkNav({signal:o}={}){t=Array.from(document.querySelectorAll(".bookmark-nav-item")),e=Array.from(document.querySelectorAll("section[id]")),t.length&&e.length&&(registerScrollHandler(o),setActiveNavItem())} //# sourceMappingURL=bookmarkNav.js.map