diff --git a/src/templates/src/education_article.html b/src/templates/src/education_article.html index 99d98b9..1d22c7f 100644 --- a/src/templates/src/education_article.html +++ b/src/templates/src/education_article.html @@ -74,11 +74,13 @@ // TOC const FUDGE = 100; const TOC_TOP_SPACING = 20; - document.addEventListener('scroll', () => { + function updateTOC() { // Stickiness + const sidebarWidth = sidebar.clientWidth; const stick = window.pageYOffset > sidebar.offsetTop-TOC_TOP_SPACING; tocContainer.style.position = stick ? 'fixed' : 'static'; tocContainer.style.top = `${TOC_TOP_SPACING}px`; + tocContainer.style.width = `${sidebarWidth}px`; // Active items let activeEntry = null; @@ -95,7 +97,9 @@ if (activeEntry) { activeEntry.link.classList.add('active'); } - }); + } + document.addEventListener('scroll', updateTOC); + window.addEventListener('resize', updateTOC); // Notes function toggleNotes() {