-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Allen Lee <[email protected]> Co-authored-by: Rachele Lang <[email protected]> Co-authored-by: Weston Ludeke <[email protected]>
- Loading branch information
1 parent
e3073d5
commit 00eb017
Showing
53 changed files
with
1,297 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/*code for the toc and case study*/ | ||
const caseStudy = document.getElementById("case-study"); | ||
const caseStudyText = document.querySelector(".prose"); | ||
const toc = document.getElementById("toc"); | ||
const tocLinks = document.querySelectorAll("#toc a"); | ||
const tocLinksCount = tocLinks.length; | ||
|
||
function isTOCVisible() { | ||
const caseStudyTopIsVisible = window.scrollY >= caseStudy.offsetTop; | ||
const caseStudyBottomIsVisible = | ||
window.scrollY + window.innerHeight > | ||
caseStudy.offsetHeight + caseStudy.offsetTop; | ||
|
||
return caseStudyTopIsVisible && !caseStudyBottomIsVisible; | ||
} | ||
function handleTOCVisibility() { | ||
if (isTOCVisible()) { | ||
toc.classList.add("show"); | ||
} else { | ||
toc.classList.remove("show"); | ||
} | ||
} | ||
console.log("JS"); | ||
// const handleTocSelection = () => { | ||
// const clearSelectedToc = () => { | ||
// const selectedTocItems = document.querySelectorAll("#toc .selected"); | ||
// const subItems = document.querySelectorAll(`li.subitem.show`); | ||
|
||
// //hide any open subitems | ||
// subItems.forEach((subItem) => { | ||
// subItem.classList.remove("show"); | ||
// }); | ||
|
||
// //remove the selected items | ||
// selectedTocItems.forEach((selectedTocItem) => { | ||
// selectedTocItem.classList.remove("selected"); | ||
// }); | ||
// }; | ||
|
||
// const selectTocItem = (link) => { | ||
// const tocItem = link.closest("li"); | ||
// const dataSection = tocItem.dataset.section; | ||
// const subItems = document.querySelectorAll( | ||
// `li.subitem[data-section="${dataSection}"]` | ||
// ); | ||
|
||
// subItems.forEach((subItem) => { | ||
// subItem.classList.add("show"); | ||
// }); | ||
|
||
// tocItem.classList.add("selected"); | ||
// }; | ||
|
||
// //do nothing if we don't want to show the toc | ||
// if (!toc.classList.contains("show")) return; | ||
|
||
// //for each link in the toc | ||
// for (let i = tocLinksCount - 1; i >= 0; i--) { | ||
// const link = tocLinks[i]; | ||
// //link.hash is the place the anchor links to. | ||
// if (!link.hash) continue; | ||
// const target = document.querySelector(link.hash); | ||
|
||
// //if the target exists and its reasonable far away | ||
// if (!!target && target.offsetTop <= window.scrollY + 16 * 2) { | ||
// clearSelectedToc(); | ||
// selectTocItem(link, target); | ||
|
||
// break; | ||
// } | ||
// } | ||
// }; |
Oops, something went wrong.