mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Fix navigation history not working after reopening book
Also remove renderer element when closing
This commit is contained in:
@@ -88,15 +88,17 @@ export class View extends HTMLElement {
|
|||||||
#searchResults = new Map()
|
#searchResults = new Map()
|
||||||
isFixedLayout = false
|
isFixedLayout = false
|
||||||
lastLocation
|
lastLocation
|
||||||
history = new History()
|
history
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
|
}
|
||||||
|
async open(book) {
|
||||||
|
this.history = new History()
|
||||||
this.history.addEventListener('popstate', ({ detail }) => {
|
this.history.addEventListener('popstate', ({ detail }) => {
|
||||||
const resolved = this.resolveNavigation(detail.state)
|
const resolved = this.resolveNavigation(detail.state)
|
||||||
this.renderer.goTo(resolved)
|
this.renderer.goTo(resolved)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
async open(book) {
|
|
||||||
this.book = book
|
this.book = book
|
||||||
this.language = languageInfo(book.metadata?.language)
|
this.language = languageInfo(book.metadata?.language)
|
||||||
|
|
||||||
@@ -130,13 +132,14 @@ export class View extends HTMLElement {
|
|||||||
this.#root.append(this.renderer)
|
this.#root.append(this.renderer)
|
||||||
}
|
}
|
||||||
close() {
|
close() {
|
||||||
this.renderer?.destroy?.()
|
this.renderer?.destroy()
|
||||||
|
this.renderer?.remove()
|
||||||
this.#sectionProgress = null
|
this.#sectionProgress = null
|
||||||
this.#tocProgress = null
|
this.#tocProgress = null
|
||||||
this.#pageProgress = null
|
this.#pageProgress = null
|
||||||
this.#searchResults = new Map()
|
this.#searchResults = new Map()
|
||||||
this.lastLocation = null
|
this.lastLocation = null
|
||||||
this.history = new History()
|
this.history = null
|
||||||
}
|
}
|
||||||
goToTextStart() {
|
goToTextStart() {
|
||||||
return this.goTo(this.book.landmarks
|
return this.goTo(this.book.landmarks
|
||||||
|
|||||||
Reference in New Issue
Block a user