We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d0d4383 commit 95f9098Copy full SHA for 95f9098
src/core/event/index.js
@@ -95,10 +95,14 @@ export function Events(Base) {
95
headingsInView[op](entry.target);
96
}
97
98
- let activeHeading = undefined;
+ let activeHeading;
99
if (headingsInView.size === 1) {
100
+ // Get first and only item in set.
101
+ // May be undefined if no headings are in view.
102
activeHeading = headingsInView.values().next().value;
103
} else if (headingsInView.size > 1) {
104
+ // Find the closest heading to the top of the viewport
105
+ // Reduce over the Set of headings currently in view (headingsInView) to determine the closest heading.
106
activeHeading = Array.from(headingsInView).reduce(
107
(closest, current) => {
108
return !closest ||
0 commit comments