A little app to serve my photography from my personal website

smooth scrolling TOC

ericwood.org 8e426679 a7aa9472

Waiting for spindle ...
+16 -2
+12 -1
src/views/blog/show/script.js
··· 5 5 intersections[el.id] = document.querySelector(`.blog__toc a[href="#${el.id}"]`); 6 6 }); 7 7 8 + Object.values(intersections).forEach((el) => { 9 + document.addEventListener("click", (event) => { 10 + event.preventDefault(); 11 + const query = event.target.getAttribute("href"); 12 + document.querySelector(query).scrollIntoView({ 13 + behavior: "smooth", 14 + }); 15 + }); 16 + }); 17 + 18 + 8 19 9 20 observer = new IntersectionObserver((entries) => { 10 21 entries.forEach((entry) => { ··· 13 24 }); 14 25 }, 15 26 { 16 - rootMargin: "-50% 0px", 27 + rootMargin: "-30% 0px -60% 0px", 17 28 }); 18 29 19 30 document.querySelectorAll(".blog__section").forEach((el) => {
+4 -1
src/views/blog/show/style.css
··· 60 60 white-space: break-spaces; 61 61 } 62 62 63 + .blog__section { 64 + scroll-margin-top: 20px; 65 + } 66 + 63 67 .blog__heading { 64 68 position: relative; 65 - scroll-margin-top: 20px; 66 69 } 67 70 68 71 .blog__heading a {