johnfactotum / foliate-js

Render e-books in the browser
https://johnfactotum.github.io/foliate-js/reader.html
MIT License
318 stars 43 forks source link

Looks very cool! Just a few questions #4

Closed j2l closed 1 year ago

j2l commented 1 year ago
johnfactotum commented 1 year ago

How to install it in a browser?

Take a look at reader.html and reader.js. Basically, you import the View class from view.js. It takes two arguments, an object that matches the book interface, and a callback that will allow you to handle events (unlike Epub.js, there are no hooks or events; everything is handled from this callback). After that, call View.display(), which returns an element which can then be appended to the page.

Do you plan, or already know, how to add page animation (flip or curl or slide or else)?

It's not too difficult to add sliding animation by modifying the #scrollTo() method in paginator.js to use behavior: 'smooth'. There are some commented bits that does exactly this. However, this only works within a section (chapter). To make it really work, it would require something like the "continuous" manager in Epub.js 0.3, which this library does not support.

As for flip or curl, I don't think it's possible with CSS columns. Well, maybe you could try and do something like four synchronized iframes. That would give you four elements that you could transform and animate. That's probably the only way, but it's not worth it in my opinion.

epubjs seems dead

To be fair, it's still receiving new commits. It's just moving slowly. And I haven't had much time to work on Foliate, either. I would say the biggest advantage of foliate-js over Epub.js is its modularity. This gives you a lot of flexibility. You can easily plug your own renderer, or add support for custom formats.

j2l commented 1 year ago

Thanks John. I'm new to epub and it looks complicated but based on html, so I decided to go back at the html source and start from here with CSS and JS.