janpio / ionic-epubjs

Ionic 3 app using Epub.js
https://janpio.github.io/ionic-epubjs/
31 stars 20 forks source link

_updateTotalPages() #37

Open PaulHost opened 6 years ago

PaulHost commented 6 years ago

Before _updateTotalPages()I can not do gotoPage(). book.generatePagination() method is very long, it may be possible to somehow skip it while saving it somewhere?

janpio commented 6 years ago

What do you mean by "very long"? That it takes long to execute?

If I remember correctly, book.gotoPage() needs to have the book fully paginated, which happens via book.generatePagination().

You can check the epubjs code and repository if there might be a better way.

PaulHost commented 6 years ago

yes, thank you!

PaulHost commented 6 years ago

It can be implemented with the locations, but I don't understand how

janpio commented 6 years ago

What does locations refer to here?

I am not fully in this project any more, so it would be great if you could search for the code here and post a link to the specific line - or some documentation.

PaulHost commented 6 years ago

you use location only as event: https://github.com/janpio/ionic-epubjs/blob/db5aa52341e86b8991ae0a057d8bb8c64fbdf5cd/src/pages/book/book.ts#L44

this.book.on('book:pageChanged', (location) => { 
        console.log('on book:pageChanged', location);
        this._updateCurrentPage();
        this._updatePageTitle();
      });

it can somehow be used for quick opening from storage https://github.com/futurepress/epub.js/blob/86ba893a29e5fef57f79b8ec4ff94a869d327324/examples/locations.html#L184

janpio commented 6 years ago

Thanks for the context.

So we listen to the book:pageChanged event which then gives a location parameter we can use and log.

I am not sure if we are using book.locations yet anywhere... the example there seems to be pretty new, right?