Merge branch 'master' of git.handmade.network:hmn/hmn
This commit is contained in:
commit
4b9fe628e6
|
@ -74,11 +74,13 @@
|
||||||
// TOC
|
// TOC
|
||||||
const FUDGE = 100;
|
const FUDGE = 100;
|
||||||
const TOC_TOP_SPACING = 20;
|
const TOC_TOP_SPACING = 20;
|
||||||
document.addEventListener('scroll', () => {
|
function updateTOC() {
|
||||||
// Stickiness
|
// Stickiness
|
||||||
|
const sidebarWidth = sidebar.clientWidth;
|
||||||
const stick = window.pageYOffset > sidebar.offsetTop-TOC_TOP_SPACING;
|
const stick = window.pageYOffset > sidebar.offsetTop-TOC_TOP_SPACING;
|
||||||
tocContainer.style.position = stick ? 'fixed' : 'static';
|
tocContainer.style.position = stick ? 'fixed' : 'static';
|
||||||
tocContainer.style.top = `${TOC_TOP_SPACING}px`;
|
tocContainer.style.top = `${TOC_TOP_SPACING}px`;
|
||||||
|
tocContainer.style.width = `${sidebarWidth}px`;
|
||||||
|
|
||||||
// Active items
|
// Active items
|
||||||
let activeEntry = null;
|
let activeEntry = null;
|
||||||
|
@ -95,7 +97,9 @@
|
||||||
if (activeEntry) {
|
if (activeEntry) {
|
||||||
activeEntry.link.classList.add('active');
|
activeEntry.link.classList.add('active');
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
document.addEventListener('scroll', updateTOC);
|
||||||
|
window.addEventListener('resize', updateTOC);
|
||||||
|
|
||||||
// Notes
|
// Notes
|
||||||
function toggleNotes() {
|
function toggleNotes() {
|
||||||
|
|
Loading…
Reference in New Issue