-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no paging slider #31
Comments
Hello, I copy here, this long extension.
|
Can you please update in this version? So I can download & see the output. |
You can copy the code above in a file and embed it in your html page after the epub.js script tag, like a sort of plugin. book.on("renderer:pagesNumChanged", onPageChange); function onPageChange() |
Sorry I haven't had a chance to review this yet. We were thinking there might be a way to get close enough to create a slider by just getting the file-size of each chapter and estimating based on that. |
Before writing that, I have also managed to implement the file size method, because, for sure, it's considerably less expensive. But I was not able to get an accurate estimation for pages number. With books heavily formatted (a lot of new lines, dialogues etc.) and, moreover, with illustrated books the estimation is quite inaccurate for me to consider that as a good result. |
Another way you could do it would be to load and render the entire epub once, generate a CFI for each "page" (say, the first visible element) and then use the list of generated CFIs as indexes in the slider (or whatever other sort of navigation control). Of course this is also an approximation, but probably a decent one under the assumption that a single user will likely be reading with the same screen each time. Changing font and style settings, margins, synthetic layout would also affect the approximation, but so it will with any method except for recalculating the number of pages dynamically (which requires the entire EPUB to be loaded in memory, as pointed out). The other benefit of this method is that you could (I think) generate the CFIs using a headless browser for a variety of different screen sizes/style settings and have them ready to go when the user loads the epub. So, for example, a list of CFIs for a single page layout on an iPhone, iPad, iPad mini etc. It might provide a better estimation than inferring from the size of un-rendered xhtml and would be more performant than having to load the entire epub. You could also do this without CFIs, but tying your "page" reference to a specific element at least provides some guarantee that you can navigate back to a position familiar to a user. Using CFIs also means that users can share their "page" reference with another user (who has a different screen size and "number of pages") and still be able to point them at about the same content. |
I suppose there isn't really a way around loading and rendering the whole book to get the page numbers, though I think for most instances a less accurate progress indicator should suffice. Finding the CFI for each page would be even more expensive then just rendering them, but it would certainly be more useful and I love the idea of being able to pre-populate it for certain screen size / fixed width book. I'll try to split up the renderer to be able to be more flexible in regards to being "headless" and make some tests to see how quickly we can generate a cfi for every page. |
Definitely true that it would be more expensive. I should have clarified my assumption, which is that it would only be used to pre-populate it for certain screen sizes. Generating CFIs for every page every time a user opens and epub would, as you said, require loading the whole epub, with CFI generation overhead on top of that. |
Regardless of the way you will choose to develop the paging system, be careful that the current implementation of CFI fails to restore the exact position within small resolutions, mostly when there are long paragraphs/elements inside a page/column. In my iPhone, with some ePubs it fails about 1 of 15 times. |
Closing this for now as much what @panurge-ws commented on was incorporated in in the Generate Pagination method. However, I think the pagination methods still need much improvement and discussion. For a first step I'm hoping to create a rough pagination method based on file size. |
Hi. I am sorry to post in this closed issue but can anyone please help me implement a paging slider. I tried @panurge-ws way of implementation above but could not get it working. Can someone please guide me. |
The important feature "paging slider" which is not included.
The text was updated successfully, but these errors were encountered: