0

fix(toc): migrate to IntersectionObserver by caugner · Pull Request #5852 · mdn/...

 2 years ago
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.

Copy link

Contributor

@caugner caugner commented 24 days ago

edited

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:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK