mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Add option to show start of main body text as defined in landmarks
This commit is contained in:
@@ -78,12 +78,16 @@ export class View extends HTMLElement {
|
|||||||
this.renderer.open(book)
|
this.renderer.open(book)
|
||||||
this.#root.append(this.renderer)
|
this.#root.append(this.renderer)
|
||||||
}
|
}
|
||||||
async init({ lastLocation }) {
|
goToTextStart() {
|
||||||
if (lastLocation) {
|
return this.goTo(this.book.landmarks
|
||||||
const resolved = this.resolveNavigation(lastLocation)
|
?.find(m => m.type.includes('bodymatter') || m.type.includes('text'))
|
||||||
|
?.href ?? this.book.sections.findIndex(s => s.linear !== 'no'))
|
||||||
|
}
|
||||||
|
async init({ lastLocation, showTextStart }) {
|
||||||
|
const resolved = lastLocation ? this.resolveNavigation(lastLocation) : null
|
||||||
if (resolved) await this.renderer.goTo(resolved)
|
if (resolved) await this.renderer.goTo(resolved)
|
||||||
|
else if (showTextStart) await this.goToTextStart()
|
||||||
else await this.renderer.next()
|
else await this.renderer.next()
|
||||||
} else await this.renderer.next()
|
|
||||||
}
|
}
|
||||||
#emit(name, detail, cancelable) {
|
#emit(name, detail, cancelable) {
|
||||||
return this.dispatchEvent(new CustomEvent(name, { detail, cancelable }))
|
return this.dispatchEvent(new CustomEvent(name, { detail, cancelable }))
|
||||||
|
|||||||
Reference in New Issue
Block a user