Skip to content

Commit

Permalink
Fix navigation history not working after reopening book
Browse files Browse the repository at this point in the history
Also remove renderer element when closing
  • Loading branch information
johnfactotum committed Jul 31, 2023
1 parent 6d1ffe1 commit c66f2e6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions view.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ export class View extends HTMLElement {
#searchResults = new Map()
isFixedLayout = false
lastLocation
history = new History()
history
constructor() {
super()
}
async open(book) {
this.history = new History()
this.history.addEventListener('popstate', ({ detail }) => {
const resolved = this.resolveNavigation(detail.state)
this.renderer.goTo(resolved)
})
}
async open(book) {

this.book = book
this.language = languageInfo(book.metadata?.language)

Expand Down Expand Up @@ -130,13 +132,14 @@ export class View extends HTMLElement {
this.#root.append(this.renderer)
}
close() {
this.renderer?.destroy?.()
this.renderer?.destroy()
this.renderer?.remove()
this.#sectionProgress = null
this.#tocProgress = null
this.#pageProgress = null
this.#searchResults = new Map()
this.lastLocation = null
this.history = new History()
this.history = null
}
goToTextStart() {
return this.goTo(this.book.landmarks
Expand Down

0 comments on commit c66f2e6

Please sign in to comment.