Sha256: 7ff47d876f89ae4da3991b608e5f40a6b25e6e25e6aa3ea68994283a07f6cd27
Contents?: true
Size: 726 Bytes
Versions: 1
Compression:
Stored size: 726 Bytes
Contents
{ if (!!window.databookConfig?.scrollspy) { window.addEventListener('load', () => { let links = Array.from(document.querySelectorAll('.c-toc__link')); let headers = links.map(x => decodeURI(x.href).split('#', 2)[1]).map(x => document.getElementById(x)); if (links.length <= 1) return; window.onscroll = () => { let scrollPosition = document.documentElement.scrollTop; let offsets = headers.map(x => x.offsetTop); offsets = offsets.map((x, i) => x - (x - ((i == 0) ? 0 : offsets[i - 1])) * .33); let target = offsets.findIndex(x => x > scrollPosition); links.forEach((link, i) => link.classList.toggle('is-active', i == target - 1)); }; }); } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
databook-theme-0.1.2 | _includes/js/scrollspy.js |