mediawiki-skins-Vector/includes
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
..
FeatureManagement Disable table of contents in article body 2021-12-16 16:11:05 -07:00
HTMLForm/Fields HTMLLegacySkinVersionField: accept string 'default' value 2021-11-23 00:57:25 -05:00
ResourceLoader Do not load common.js twice 2022-01-25 20:10:31 +00:00
Services search: Disable query highlight for some languages 2021-06-30 16:47:46 +01:00
templates Add sectionObserver and tableOfContents component JS to respond to intersection changes 2022-01-26 14:11:43 -07:00
Constants.php Respect useskin when operating in MigrationMode 2022-01-19 22:33:28 +00:00
Hooks.php Do not try to make watchlist collapsible on wikis where watchlist is disabled 2022-01-20 09:42:58 -08:00
ServiceWiring.php Drop watchlist in user menu feature flag 2022-01-19 16:10:32 +00:00
SkinVector.php Opt in link should be different in migration mode 2022-01-25 00:54:51 +00:00
SkinVector22.php Restore gadget support to new internal skins 2022-01-07 00:18:17 +00:00
SkinVectorLegacy.php Vector is split into 2 skins 2022-01-06 15:52:10 -08:00
SkinVersionLookup.php Fix bug in SkinVersionLookup 2022-01-24 13:34:06 -08:00
VectorServices.php search: Disable query highlight for some languages 2021-06-30 16:47:46 +01:00