Skip to content
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

Merged
merged 18 commits into from
Jan 14, 2022

Conversation

choldgraf
Copy link
Member

@choldgraf choldgraf commented Jan 2, 2022

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.

@choldgraf
Copy link
Member Author

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?

@choldgraf
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant