Add EPUBNavigatorViewController
's viewport
#612
Merged
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.
Added
Navigator
viewport
property of anEPUBNavigatorViewController
to obtain information about the visible portion of the publication, including the visible positions and reading order indices.The initial use case that motivated this PR is the need to display a range of visible positions to the user (e.g.,
5-6 of 120
). This helps prevent confusion when turning pages "skips" several positions.I initially considered adding a second locator representing the "last visible locator", but this solution has some issues:
Locator
is not typed for each navigator. We want to move away from usingLocator
in the APIs and keep it as a serialization and exchange format only.position
, but itsprogression
will actually be the beginning of the next "screen page" (as it is the same as the last scroll progression of the current screen page). Therefore the locator would contain two incompatible values.After thinking more about this problem, I believe we should separate the current location (e.g. used for restoring the reading progression) from information about the rendering, which could actually contain more information that the last visible position (e.g. the list of reading order items currently displayed).
In this PR I added a new
viewport
property in the EPUB navigator which can be used to report information about the visible portion of a publication in the navigator. Currently it contains only two informations:positions: ClosedRange<Int>
- a range of visible positions, e.g5...6
readingOrderIndices: ClosedRange<ReadingOrder.Index>
- a contiguous range of indexes of the visible resources from thereadingOrder
.@qnga @JayPanoz @chocolatkey I would love to get your opinion on this as we will likely need to align the implementations at some point.