mirror of
https://github.com/tchartron/blow
synced 2024-12-03 17:49:17 +00:00
update
This commit is contained in:
parent
1eab37c612
commit
eaaa5445da
2 changed files with 3 additions and 3 deletions
|
@ -14,12 +14,13 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
const page_titles_elements = document.querySelectorAll(page_titles_ids.join(','));
|
||||
console.log(page_titles_elements)
|
||||
|
||||
let reversed_title_elements = [...page_titles_elements].reverse();
|
||||
window.addEventListener('scroll', () => {
|
||||
if (current_active_toc_link === false) {
|
||||
table_of_content_links[0].classList.add('bg-blue-800')
|
||||
current_active_toc_link = table_of_content_links[0]
|
||||
} else {
|
||||
console.log(setActiveToc(page_titles_elements))
|
||||
console.log(setActiveToc(reversed_title_elements))
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -164,7 +165,6 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
// })
|
||||
});
|
||||
function setActiveToc(elements) {
|
||||
// elements.reverse();
|
||||
return [...elements].find((item) => {
|
||||
return (item.getBoundingClientRect().y < 0)
|
||||
})
|
||||
|
|
|
@ -1 +1 @@
|
|||
function setActiveToc(e){return[...e].find(e=>e.getBoundingClientRect().y<0)}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc");const e=document.querySelectorAll("#toc li a");document.getElementById("page-content");let t=!1,n=[];[...e].forEach(e=>{n.push(e.href.substring(e.href.indexOf("#")))});const o=document.querySelectorAll(n.join(","));console.log(o),window.addEventListener("scroll",()=>{!1===t?(e[0].classList.add("bg-blue-800"),t=e[0]):console.log(setActiveToc(o))})});
|
||||
function setActiveToc(e){return[...e].find(e=>e.getBoundingClientRect().y<0)}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc");const e=document.querySelectorAll("#toc li a");document.getElementById("page-content");let t=!1,n=[];[...e].forEach(e=>{n.push(e.href.substring(e.href.indexOf("#")))});var o=document.querySelectorAll(n.join(","));console.log(o);let c=[...o].reverse();window.addEventListener("scroll",()=>{!1===t?(e[0].classList.add("bg-blue-800"),t=e[0]):console.log(setActiveToc(c))})});
|
Loading…
Reference in a new issue