allenai / pdf-component-library

44 stars 4 forks source link

Fix Page numbers don't update when navigating with thumbnails #202

Open huytr1995 opened 1 year ago

huytr1995 commented 1 year ago

Description

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

Since we recently are having issue with PageNumberControl due to user scrolls speed so this PR addresses this.

Reviewer Instructions

According to the video in the beginning Smita is already at page 15 but the page control is displaying it as page 6 so this can be the case that Smita scrolled faster than IntersectionObserver API picks up the change so that's why our page control can't update accordingly. So i change the threshold to 0 which mean if as soon as a tiny bit of the div is visible, IntersectionObserver will kick in.

Testing Plan

Verify when scroll manually through the page, the page number updated accordingly. Also when clicking thumbnail or TOC it will update the page number accordingly.

Output / Screenshots

https://user-images.githubusercontent.com/84343285/195228200-bbc6e796-cc18-4d68-8734-b029393919e2.mov

A11y

N/A

huytr1995 commented 1 year ago

@ericmarsh995 i tested by banging my mouse wheel real fast and it seem be able to keep up in page tracking correctly so i think this is it.

ericmarsh995 commented 1 year ago

Have you tested this on S2? Also, it might make sense to set it to 0.5 instead of 0 as most readers update the page when its halfway through

huytr1995 commented 1 year ago

Have you tested this on S2? Also, it might make sense to set it to 0.5 instead of 0 as most readers update the page when its halfway through

The recording is basically tested in s2 @ericmarsh995 i tried with 0.5 but its still not picking fast enough. 0 picks up faster since even with one tiny pixel can trigger intersection observer. @ericmarsh995 video is uploaded correctly now by testing in Prod.