Merge branch 'master' of git.handmade.network:hmn/hmn
This commit is contained in:
commit
4b9fe628e6
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue