0
fix(toc): migrate to IntersectionObserver by caugner · Pull Request #5852 · mdn/...
source link: https://github.com/mdn/yari/pull/5852
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Summary
This makes the "In this article" table of contents (TOC) more reliable.
Fixes mdn/foxfooding-mdn-plus#63.
Problem
Previously, we determined the currently viewed section
"In this article" by listening to the scroll event.
Solution
Now, we use an IntersectionObserver to get notified when relevant sections move in/out of the viewport.
Screenshots
Before
Screen.Recording.2022-03-29.at.19.59.30.mov
After
Screen.Recording.2022-04-05.at.12.45.21.mov
How did you test this change?
Tested scrolling locally on these pages:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK