Auto scroll sticky ToC with content (#3115)
This commit is contained in:
parent
7ef6af66e4
commit
dc41016c62
@ -81,6 +81,23 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
// Auto scroll sticky ToC with content
|
||||
document.addEventListener("gumshoeActivate", function (event) {
|
||||
var target = event.target;
|
||||
var scrollOptions = { behavior: "auto", block: "nearest", inline: "start" };
|
||||
|
||||
var tocElement = document.querySelector("aside.sidebar__right.sticky");
|
||||
if (!tocElement) return;
|
||||
if (!window.getComputedStyle(tocElement).position !== "sticky") return;
|
||||
|
||||
if (target.parentElement.classList.contains("toc__menu") && target == target.parentElement.firstElementChild) {
|
||||
// Scroll to top instead
|
||||
document.querySelector("nav.toc header").scrollIntoView(scrollOptions);
|
||||
} else {
|
||||
target.scrollIntoView(scrollOptions);
|
||||
}
|
||||
});
|
||||
|
||||
// add lightbox class to all image links
|
||||
$(
|
||||
"a[href$='.jpg'],a[href$='.jpeg'],a[href$='.JPG'],a[href$='.png'],a[href$='.gif'],a[href$='.webp']"
|
||||
|
4
assets/js/main.min.js
vendored
4
assets/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user