readium / swift-toolkit

A toolkit for ebooks, audiobooks and comics written in Swift
https://readium.org/mobile/
BSD 3-Clause "New" or "Revised" License
256 stars 101 forks source link

Navigator places locator with anchor in the middle of the screen in scroll mode #328

Closed chrfalch closed 1 year ago

chrfalch commented 1 year ago

Bug Report

When an EPub navigator is in scroll mode and navigating to a locator with an anchor (ex.: /OEBPS/chapter16.xhtml#endnote-022), the scroll position is calculated to place the target element in the middle of the screen. This can be an issue for footnotes in large indexes because it might not be clear which footnote that was clicked:

https://github.com/readium/swift-toolkit/assets/875252/65522957-e368-4d41-be86-17fb4f1922f3

Expected behavior

It might look / feel better to place the target element at the top of the screen to put emphasis on the element to avoid it drowning among other footnotes:

https://github.com/readium/swift-toolkit/assets/875252/ee052567-72cd-40df-9811-00c8cabd24d0

How to reproduce?

  1. Open a book that contains footnotes
  2. Ensure the navigator is in scroll mode
  3. Click on a footnote link
  4. See error

Additional discussion

It makes sense to present the target element in the middle for context other than footnotes - like links back from the footnote. It is however easier to understand the context when going back than when going into footnotes.

Additional context