mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Add an EventTarget for transforming the book
And use it to do paginator-specific CSS replacements. And use it to catch loading errors in reader.js. Fixes #14 Closes #18
This commit is contained in:
@@ -112,6 +112,8 @@ The following methods are consumed by `progress.js`, for getting the correct TOC
|
||||
- `.splitTOCHref(href)`: given an href string (from the TOC), returns an array, the first element of which is the `id` of the section (see above), and the second element is the fragment identifier (can be any type; see below). May be async.
|
||||
- `.getTOCFragment(doc, id)`: given a `Document` object and a fragment identifier (the one provided by `.splitTOCHref()`; see above), returns a `Node` representing the target linked by the TOC item
|
||||
|
||||
In addition, the `.transformTarget`, if present, can be used to transform the contents of the book as it loads. It is an `EventTarget` with a custom event `"data"`, whose `.detail` is `{ data, type, name }`, where `.data` is either a string or `Blob`, or a `Promise` thereof, `.type` the content type string, and `.name` the identifier of the resource. Event handlers should mutate `.data` to transform the data.
|
||||
|
||||
Almost all of the properties and methods are optional. At minimum it needs `.sections` and the `.load()` method for the sections, as otherwise there won't be anything to render.
|
||||
|
||||
### Archived Files
|
||||
|
||||
Reference in New Issue
Block a user