-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAINT: Simplify toc scrolling behavior #448
Conversation
Will leave this one open a bit to see if others have thoughts on the slightly new behavior. Maybe @AakashGfude wants to give it a look since he's going to do a deeper dive on the theme infrastructure? |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
OK I got the interactionobserver working for the scroll behavior as well, so this PR no longer changes the default style of pages, it only improves the "watching" behavior for margin content. I think that this is good to go |
This simplifies the logic behind our scrolling behavior so that we are relying on a less-opaque and a more performant method for deciding when to hide the Table of Contents.
Old method: The way we currently do this is by setting up a callback that fires every time somebody scrolls, calculates the vertical position of every margin element, calculates whether it overlaps with the table of contents, and hides the TOC if they overlap.
New method: Uses the Intersection Observer API to detect whether an element is on screen. This will only fire when an elements visibility has changed, not on every scroll. This should help performance a decent amount, and is a less hacky way to do things in general.