From 6d1ffe1b8122274c5614397c0b0d59c2630eb7b5 Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Wed, 5 Jul 2023 10:33:32 +0800 Subject: [PATCH] Save more location info --- view.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/view.js b/view.js index 1834fcd..82f03da 100644 --- a/view.js +++ b/view.js @@ -123,7 +123,7 @@ export class View extends HTMLElement { this.renderer.addEventListener('load', e => this.#onLoad(e.detail)) this.renderer.addEventListener('relocate', e => this.#onRelocate(e.detail)) this.renderer.addEventListener('snapend', () => - this.history.replaceState(this.lastLocation)) + this.history.replaceState(this.lastLocation.cfi)) this.renderer.addEventListener('create-overlayer', e => e.detail.attach(this.#createOverlayer(e.detail))) this.renderer.open(book) @@ -164,8 +164,8 @@ export class View extends HTMLElement { const tocItem = this.#tocProgress.getProgress(index, range) const pageItem = this.#pageProgress.getProgress(index, range) const cfi = this.getCFI(index, range) - this.lastLocation = cfi - this.#emit('relocate', { ...progress, tocItem, pageItem, cfi, range }) + this.lastLocation = { ...progress, tocItem, pageItem, cfi, range } + this.#emit('relocate', this.lastLocation) } #onLoad({ doc, index }) { // set language and dir if not already set @@ -332,11 +332,11 @@ export class View extends HTMLElement { } async prev() { await this.renderer.prev() - this.history.replaceState(this.lastLocation) + this.history.replaceState(this.lastLocation.cfi) } async next() { await this.renderer.next() - this.history.replaceState(this.lastLocation) + this.history.replaceState(this.lastLocation.cfi) } goLeft() { return this.book.dir === 'rtl' ? this.next() : this.prev()