Syllabus/static/js/sandpoints.js

29 lines
1.3 KiB
JavaScript

window.addEventListener('scroll', function(e) {
let element = document.querySelector('.topicstitle')
let topicbar = document.querySelector('.topicbar')
let grid = document.querySelector('.grid')
let rect = element.getBoundingClientRect();
if (rect.top < 12 && !grid.classList.contains('moved')) {
topicbar.style.display = "inline";
element.style.visibility = "hidden";
grid.classList.add('moved');
grid.style.display = "none";
window.scrollBy({top: grid.clientHeight + element.clientHeight, behavior: 'smooth'})
} else if (rect.top > 11 && grid.classList.contains('moved')) {
grid.style.display = "grid";
grid.classList.remove('moved');
topicbar.style.display = "none";
element.style.visibility = "visible";
window.scroll({top: 0, behavior: 'smooth'})
}
})
window.addEventListener('DOMContentLoaded', (e) => {
console.log("SHUFFLE!")
let par = document.querySelector("#TableOfContents > ol:first-child > li:first-child");
let s = document.createElement("span");
s.appendChild(par.cloneNode(true))
par.remove()
document.querySelector("#TableOfContents > ol:first-child").insertBefore(s, document.querySelector("#TableOfContents > ol:first-child").firstChild)
})