Skip to content

Fix scrollLeft resetting while scrolling in 1up on Chrome/Firefox - #1575

Merged
cdrini merged 2 commits into
internetarchive:masterfrom
cdrini:fix/scroll-jitter
Jul 28, 2026
Merged

Fix scrollLeft resetting while scrolling in 1up on Chrome/Firefox#1575
cdrini merged 2 commits into
internetarchive:masterfrom
cdrini:fix/scroll-jitter

Conversation

@cdrini

@cdrini cdrini commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Calling getBoundingClientRect() during text layer rendering was forcing a synchronous reflow of the whole document -- for some reason resetting the scroll. So now we create a temporary iframe where we call getBoundingClientRect, which does not!

QA: https://deploy-preview-1575--ia-bookreader.netlify.app/bookreaderdemo/demo-internetarchive?ocaid=theworksofplato01platiala

To reproduce:

  1. Open a book in mobile
  2. Click on "fullscreen"
  3. Zoom in and scroll left some amount
  4. Scroll down past a few pages

Expected behaviour: Your scroll left position should stay the same
Actual behaviour: It resets to the edge after a page or so

Recording.2026-07-24.145908.mp4

Calling getBoundingClientRect() during text layer rendering was forcing
a synchronous reflow of the whole document -- for some reason resetting
the scroll. So now we create a temporary iframe where we call
getBoundingClientRect, which does not!

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.70%. Comparing base (172ce56) to head (74a669b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1575      +/-   ##
==========================================
+ Coverage   63.64%   63.70%   +0.05%     
==========================================
  Files          68       68              
  Lines        6206     6216      +10     
  Branches     1378     1378              
==========================================
+ Hits         3950     3960      +10     
  Misses       2217     2217              
  Partials       39       39              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cdrini cdrini changed the title Fix scrollLeft resetting while scrolling in 1up Fix scrollLeft resetting while scrolling in 1up on Chrome/Firefox Jul 24, 2026

@nsharma123 nsharma123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the iframe-based measurement fix. The core idea (measuring in a detached, non-scrolling iframe instead of the live document) looks solid and I confirmed it builds, lints, and passes the existing Jest suite. Left two inline comments: one is a confirmed regression (repro'd locally), the other is a resource-leak concern worth considering.

Comment thread src/plugins/plugin.text_selection.js
Comment thread src/plugins/plugin.text_selection.js
@cdrini
cdrini merged commit 0d8cef0 into internetarchive:master Jul 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants