Gallery
Last updated
Was this helpful?
Last updated
Was this helpful?
This enhancer gives you methods to facilitate creation of gallery of pages. This can be helpful to provide a quick overview and / or navigation for a book.
The gallery enhancer does not create a gallery for you, it will help you gather snapshot of pages that you can then display in your own gallery. This way it's agnostic and you are responsible for your entire design.
Connect the enhancer to your reader:
The API is under the gallery
namespace.
.snapshot()
This method takes a spine item and a given dimension for snapshot and will provide you with an copy of the relevant document (first page) scaled to your dimensions and centered. This will be an exact copy of how the page would look like in your current reader. It will however try to cleanup it and only keep the rendered document. This means that things like annotations, customization to spine item will not be taken into account.
The parent element needs to be passed down as well as we will attach the snapshot to it automatically. This is needed for internal iframe loading events check.
You may be wondering why we don't use a tool like https://html2canvas.hertzen.com/ to create a snapshot. Drawing the iframe in a canvas would be much more memory efficient and easier to manipulate but it only works with same origin content. This is too big of a restriction to be used as default method.