Replies: 5 comments
-
If by chapter you mean from the table of contents, then it's not possible at the moment. However, if you mean the current resource, then: let totalResources = publication.readingOrder.count
func navigator(_ navigator: Navigator, locationDidChange locator: Locator) {
let currentResourceIndex = (publication.readingOrder. firstIndex { $0.href == locator.href } ?? 0) + 1
} |
Beta Was this translation helpful? Give feedback.
-
thank @mickael-menu. I would like to ask 1 more question. Can the library get all page numbers in the chapter and page numbers in the currently open chapter? |
Beta Was this translation helpful? Give feedback.
-
Yes, we call these "positions" in our architecture, see https://github.com/readium/architecture/tree/master/models/locators/positions You can use it like that: // Total number of positions in the publication
let totalPositions = publication.positionList.count
// Total number of positions in one chapter
let totalPositionsInResource = publication.positionListByResource[href].count
func navigator(_ navigator: Navigator, locationDidChange locator: Locator) {
// Current position in the visible resource (starting from 1)
locator.locations.position
} (Note: |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
That's normal, we can have more (or less) positions per "screen page", so the last page in this case contains 6 positions, and we report the first position in it (19). Unfortunately, we don't have any reliable way to report real screen page numbers for reflowable EPUBs, because it depends on the size of the screen, user settings, font size, etc. We could calculate it for the current chapter, but not for the whole publication, so that would be pointless. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions