Fix currentLocator not updating after changing EPUB preferences - #819
Draft
mickael-menu wants to merge 1 commit into
Draft
mickael-menu wants to merge 1 commit into
mickael-menu wants to merge 1 commit into
Conversation
In the legacy EPUB navigator, changing reading preferences that trigger a relayout (e.g. font size) did not emit a new currentLocator. Apps persisting the locator to restore the reading position would reopen the publication pages away from where the user left off. The JS ResizeObserver already reacted to content relayouts to snap the scroll offset, but never notified the native side - unlike the Swift toolkit, where it posts a progressionChanged message. Add an Android.onContentSizeChanged() bridge call in that observer, which triggers the existing debounced and guarded notifyCurrentLocation() path to emit a locator reflecting the actual position after the reflow. Fixes #761 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This branch has not been deployed
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.
In the legacy EPUB navigator, changing reading preferences that trigger a relayout (e.g. font size) did not emit a new
currentLocator. Apps persisting the locator to restore the reading position would reopen the publication pages away from where the user left off.The JS
ResizeObserveralready reacted to content relayouts to snap the scroll offset, but never notified the native side — unlike the Swift toolkit, where it posts aprogressionChangedmessage after every relayout. This adds anAndroid.onContentSizeChanged()bridge call in that observer, which triggers the existing (debounced and guarded)notifyCurrentLocation()path to emit a locator reflecting the actual position after the reflow. JS bundles regenerated withmake scripts.Note: re-anchoring to the exact pre-change position (readium/swift-toolkit#645) is out of scope; the emitted locator reflects where the reflow actually leaves the user.
Needs on-device verification: change font size → close → reopen should preserve the position (within a page), in paginated and scroll modes; sanity-check an FXL publication and rotation for spurious emissions.
Fixes #761
🤖 Generated with Claude Code