diff --git a/eleventy.config.js b/eleventy.config.js index f5a13d9..513ebc9 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -561,6 +561,7 @@ export default function (eleventyConfig) { attrs: { class: "sidenote", "aria-label": `Sidenote ${label}`, + "data-fn-ref": refId, }, content: [ { @@ -594,7 +595,10 @@ export default function (eleventyConfig) { // getBoundingClientRect() is viewport-relative; subtracting eRect.top from // hRect.top gives the distance of the host from .e-content top, which equals // the CSS `top` value needed for an absolute child of .e-content. - const posScript = `(function(){var a,e,mc;function p(){if(window.innerWidth<1440){if(e){e.style.position='';e.style.overflowX='';}if(mc)mc.style.overflowX='';return;}if(!a)a=document.querySelector('article.has-sidenotes');if(!a)return;if(!e)e=a.querySelector('.e-content');if(!e)return;if(!mc)mc=a.closest('.main-content');e.style.position='relative';e.style.overflowX='visible';if(mc)mc.style.overflowX='visible';var er=e.getBoundingClientRect();var lb=0;a.querySelectorAll('.sidenote').forEach(function(s){var h=s.parentElement;var hr=h.getBoundingClientRect();var t=Math.max(hr.top-er.top,lb);s.style.top=t+'px';lb=t+s.offsetHeight+8;});}requestAnimationFrame(p);window.addEventListener('load',p);window.addEventListener('resize',p);})();`; + // Browsers re-parent