-
Notifications
You must be signed in to change notification settings - Fork 69
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
Table of content #199
Table of content #199
Conversation
Try to scroll this page: https://docs-stage.codex.so/how-to-connect-to-mongo |
This reverts commit 18aad62.
Maybe we should hide table of contents on narrow screens? Seems like it is useless when it is at the bottom of the page |
it could be used as a quick teleport to headers from the end of the article. actually i don't know do we need to show it on mobile devices. need to ask product owner to make a decision.
|
* If fixed header is present then calculate scroll position based on it | ||
*/ | ||
if (this.fixedHeaderSelector) { | ||
const fixedHeader = document.querySelector(this.fixedHeaderSelector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't call dom search on every scroll. Do it once before the hadler.
/** | ||
* Calculate scroll position | ||
*/ | ||
let lastKnownScrollPosition = 1 + window.scrollY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic number
const fixedHeader = document.querySelector(this.fixedHeaderSelector); | ||
|
||
if (fixedHeader) { | ||
lastKnownScrollPosition += fixedHeader.getBoundingClientRect().height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that will fire reflow on every scroll handler. To prevent this, call this method once before the handler since it wont change with scroll.
calculateBoundings() { | ||
this.tagsSectionsMap = this.tags.map((tag) => { | ||
const rect = tag.getBoundingClientRect(); | ||
const top = rect.top + window.scrollY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this method resolves your problem, you can use the polyfill for safari |
resolves #176