With Paul's original code it will give us multiple pages if we are between two pages. So one way to tackle this is we need to convert from a Set() to Map(). Thanks to IntersectionObserverEntry it will provide us the intersectionRatio to see which one is closer to the viewport.
Testing Plan
Add console.log in ScrollContext toward end to see the value of VisiblePages & VisbleOutlineTarget. Changing unit test format to fit with Map() value and verify no unit test fail.
Description
Ref: https://github.com/allenai/scholar/issues/32907 After adding scroll direction its time to add ability to detecting current page & outline to ScrollContext
Reviewer Instructions
With Paul's original code it will give us multiple pages if we are between two pages. So one way to tackle this is we need to convert from a Set() to Map(). Thanks to IntersectionObserverEntry it will provide us the intersectionRatio to see which one is closer to the viewport.
Testing Plan
Add console.log in ScrollContext toward end to see the value of VisiblePages & VisbleOutlineTarget. Changing unit test format to fit with Map() value and verify no unit test fail.
Output / Screenshots
https://user-images.githubusercontent.com/84343285/180864127-21c3b502-a2aa-477e-8597-8279c6a51f73.mov
A11y
No A11y involvement