Fix scrollLeft resetting while scrolling in 1up on Chrome/Firefox - #1575
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
nsharma123
reviewed
Jul 28, 2026
nsharma123
left a comment
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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