readium/r2-navigator-swift

Can I get the current page and spine with NavigatorViewController?

ClassWizard opened this issue · 4 comments

I want to know the current page and spine which user is reading. Therefore, I can show the reading progress.
TriptychView has a property (index) can do this, but It's a private property.

Hello @ClassWizard currently the progress isn't implemented, the index property is private because it's still a internal way of knowing position and may not be fully adequate for progress indication.
It's in the roadmap, but any contribution is welcome.

Here is the link to the current discussion about Locators:
https://github.com/readium/readium-2/tree/master/locators

Hello @camill-a ,thanks for your immediate reply. I read the document. Now I understand that the progress function could be supported by The Locators ,which is seems to be another independent framework. There still some other questions, I will be very grateful if you could give me some advice.

I forked this repository, and added a delegate so that I can learn about the spine changing.(I use it for transition) But then I found that I was on an wrong way. Because I just invoke the delegate method when the TriptychView rebuild its views. Later, I found only when the resource (html file) changed,the TriptychView would rebuild its views. Some chapters or sections may be in a same html file.
Before I choose this way,I firstly tried to use the scrollView delegate. But soon I found its contentSize is just the size of screen(width). So I gave up.

How can I listen the reading content changed, I supposed it's the navigator's job.

So there are two types of pages, the next/previous part of the paginated document and the first/last page of the next/previous document, if that's clear.
The next/previous page inside a document is a native scrolling inside the WebView (not handled by us, but it would be detectable in JS looking at the current x position in the document).
The next/previous page document to document is the TryptichView's views sliding right/left, and that's called by the WebView when we ask for next/prev on the document maxX or 0 respectively.
You can see the logic looking at the Scroll enum in WebView, calling viewDelegate protocol methods implemented by the NavigatorViewController (who then call the TryptichView)

The mentioned Locator model is being implemented in the navigators and will be available soon. This should remove any need to fiddle with the internals of the TryptichView.