@xiee/utils
Advanced tools
Comparing version 1.12.16 to 1.12.17
@@ -8,3 +8,3 @@ // highlight a TOC item when scrolling to a corresponding section heading | ||
if (!links.length) return; | ||
const lis = toc.querySelectorAll('li'), dict = {}; | ||
const dict = {}; | ||
links.forEach(a => dict[a.getAttribute('href').replace('#', '')] = a); | ||
@@ -30,5 +30,2 @@ const ids = Object.keys(dict); | ||
} | ||
lis.forEach(li => { | ||
li.classList[li.querySelector('.active') ? 'add' : 'remove']('open'); | ||
}); | ||
})); | ||
@@ -35,0 +32,0 @@ |
@@ -1,1 +0,1 @@ | ||
(e=>{const t=e.querySelector("#TableOfContents, #TOC");if(!t)return;const r=t.querySelectorAll('a[href^="#"]');if(!r.length)return;const n=t.querySelectorAll("li"),o={};r.forEach((e=>o[e.getAttribute("href").replace("#","")]=e));const c=Object.keys(o),s=[],l=new IntersectionObserver((e=>e.forEach((e=>{const t=e.target.id,r=s.indexOf(t);let l;e.isIntersecting?s.push(t):r>-1&&s.splice(r,1);const i=s.length;if(i)l=s[i-1];else{if(e.target.getBoundingClientRect().top<0)return;const r=c.indexOf(t)-1;r>=0&&(l=c[r])}for(const e in o)o[e].classList[e===l?"add":"remove"]("active");n.forEach((e=>{e.classList[e.querySelector(".active")?"add":"remove"]("open")}))}))));e.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((e=>{1===e.nodeType&&o.hasOwnProperty(e.id)&&l.observe(e)}))})(document); | ||
(e=>{const t=e.querySelector("#TableOfContents, #TOC");if(!t)return;const r=t.querySelectorAll('a[href^="#"]');if(!r.length)return;const n={};r.forEach((e=>n[e.getAttribute("href").replace("#","")]=e));const o=Object.keys(n),c=[],s=new IntersectionObserver((e=>e.forEach((e=>{const t=e.target.id,r=c.indexOf(t);let s;e.isIntersecting?c.push(t):r>-1&&c.splice(r,1);const i=c.length;if(i)s=c[i-1];else{if(e.target.getBoundingClientRect().top<0)return;const r=o.indexOf(t)-1;r>=0&&(s=o[r])}for(const e in n)n[e].classList[e===s?"add":"remove"]("active")}))));e.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((e=>{1===e.nodeType&&n.hasOwnProperty(e.id)&&s.observe(e)}))})(document); |
{ | ||
"name": "@xiee/utils", | ||
"version": "1.12.16", | ||
"version": "1.12.17", | ||
"description": "Miscellaneous tools and utilities to manipulate HTML pages", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1937
113821