allenai / pdf-component-library

44 stars 4 forks source link

Fixing the scroll logic when it comes to root element #147

Closed huytr1995 closed 2 years ago

huytr1995 commented 2 years ago

Description

Ref: https://github.com/allenai/scholar/issues/32904

With the none legacy_reader layout the scroll is not existing in any of the react-pdf or S2 side any more but instead existing in browser level. This PR helps to unblock Eric from not be able to detect UP or DOWN when scrolling in none legacy layout

Reviewer Instructions

Since the none legacy layout scroll is existing on browser so in the ScrollDirection this._el.addEventListener wont work for document.documentElement. Instead we have to usewindow.addEventListener

Testing Plan

Run yarn buildand copy the build file and paste into the node_module of S2 @allenai/pdf-componentsto verify if we console.log the scroll direction it should work.

Output / Screenshots

https://user-images.githubusercontent.com/84343285/180267671-c3c045f9-5833-4f45-ae39-6810461807fd.mov

A11y

No A11y involvement