Skip to content

Conversation

@arturhg
Copy link
Contributor

@arturhg arturhg commented Jan 15, 2026

Summary

  • Fixed scroll position not being restored when switching between documents during a session
  • The issue was that the scroll value read from the scrollbar was unreliable after zoom operations modified it
  • Fixed by storing the scroll value directly when loading from the edit file, and reading from that stored value instead of the scrollbar

Root Cause

When opening a document:

  1. loadEdition() reads lastScrollValue from YAML and sets vScrollBar.setValue()
  2. The subsequent zoom adjustment overwrites the scrollbar value
  3. Original code read vScrollBar.getValue() after the zoom adjustment, getting the wrong value

Solution

  • Added loadedScrollValue field in Edition.java to store the scroll value when loaded from file
  • Read from that stored value instead of the scrollbar in MainScreen.java
  • Apply with Platform.runLater() to ensure UI is ready

Test done

  • Open a PDF, add annotation, scroll to a position
  • Switch to another PDF
  • Switch back - scroll position is now restored correctly

Closes #215

The scroll position was not being restored when switching between
documents during a session. The issue was that the scroll value read
from the scrollbar was unreliable after zoom operations modified it.

Fixed by storing the scroll value directly when loading from the edit
file, and reading from that stored value instead of the scrollbar.

Closes ClementGre#215
@arturhg arturhg changed the title fix(scroll): Restore scroll position when switching between documents Restore scroll position when switching between documents Jan 15, 2026
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.

Garder en mémoire la dernière page visitée pour chaque document

1 participant