mediawiki-skins-Vector/includes/templates
Nicholas Ray 3c433a5315 Add sectionObserver and tableOfContents component JS to respond to intersection changes
This commits sets up the Table of Contents to bold the active section
when the section is scrolled.

Unfortunately, because our content does not have actual sections but
instead has a flat list of headings and paragraphs, we can't use
IntersectionObserver in the conventional way as it is optimized to find
intersections of elements that are *within* the viewport and the
callback will not reliably fire during certain scenarios (e.g. with fast
scrolling or when the headings are not currently within the viewport).
Furthermore, iterating through a list of elements and calling
`getBoundingClientRect()` can be expensive and can also cause
significant forced synchronous layouts that block the main thread.

The best compromise in terms of performance and function that I've found
is to use a combination of a throttled scroll event listener and
IntersectionObserver's ability to asyncronously find the
boundingClientRect of all elements off the main thread when `.observe`
is called which is the approach this patch takes. Although this is an
unorthodox way to use IntersectionObserver, performance profiles
recorded while holding the "down" arrow and scrolling for 10 seconds
with a 6x CPU throttle are comparable between master and this patch:

master: https://phabricator.wikimedia.org/F34930737
this patch:  https://phabricator.wikimedia.org/F34930738

Bug: T297614
Change-Id: I4077d86a1786cc1f4a7d85b20b7cf402960940e7
2022-01-26 14:11:43 -07:00
..
legacy Storybook should include UserLinks 2021-05-27 19:27:27 +00:00
Button.mustache Fix icon button spacing, make it consistent with margin defined in core 2021-11-18 18:55:00 +00:00
Footer.mustache Use content-parser-output RL SkinModule feature 2021-03-25 17:34:28 +00:00
Footer__row.mustache templates: Move spaces into conditions for cleaner html 2021-09-29 14:06:07 +02:00
Header.mustache [Storybook] Add Header component 2021-09-14 18:33:10 +00:00
Indicators.mustache Remove mw-body-content from HTML that is not the article body 2021-05-14 00:01:52 +00:00
Logo.mustache Logo scales with font-size 2021-09-28 21:44:53 +00:00
Menu.mustache Restores language button icon font size 2021-12-01 01:08:49 +00:00
Navigation.mustache Improve heading structure and heading semantics by removing redundant headings and labels for modern Vector 2021-09-14 10:47:05 -05:00
SearchBox.mustache templates: Move spaces into conditions for cleaner html 2021-09-29 14:06:07 +02:00
Sidebar.mustache Add language switching alert in sidebar for language in header 2021-12-09 16:37:36 -07:00
SidebarAction.mustache Remove need for html-class template property 2021-12-10 08:40:01 -08:00
skin-legacy.mustache Vector uses html-title-heading 2021-12-15 22:27:48 +00:00
skin.mustache Use 'toc' skin option and render with new TableOfContents mustache template 2022-01-19 14:38:51 -06:00
StickyHeader.mustache Fix article title in sticky header template. 2021-10-18 14:00:47 -06:00
TableOfContents.mustache Add sectionObserver and tableOfContents component JS to respond to intersection changes 2022-01-26 14:11:43 -07:00
UserLinks.mustache Consolidate user links outside of the user menu dropdown into a single new menu 2021-07-15 20:27:54 +00:00
UserLinks__login.mustache User menu design tweaks 2021-07-27 14:25:32 -06:00
UserLinks__logout.mustache [a11y] Add title attributes to logout, talk and history and DRY up code. 2021-10-19 08:47:00 -07:00
UserLinks__more.mustache [Refactor] simplify watchlist link generation and adopt new icon 2022-01-14 00:26:10 +00:00