Fix history state not updated when swiping

This commit is contained in:
John Factotum
2023-05-27 00:04:26 +08:00
parent 772cbe00ca
commit 36a8fb62e7
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -608,7 +608,7 @@ export class Paginator extends HTMLElement {
index: this.#adjacentIndex(dir), index: this.#adjacentIndex(dir),
anchor: dir < 0 ? () => 1 : () => 0, anchor: dir < 0 ? () => 1 : () => 0,
}) })
}) }).then(() => this.dispatchEvent(new Event('snapend')))
} }
#onTouchStart(e) { #onTouchStart(e) {
const touch = e.changedTouches[0] const touch = e.changedTouches[0]
+2
View File
@@ -120,6 +120,8 @@ export class View extends HTMLElement {
this.renderer.setAttribute('exportparts', 'head,foot,filter') this.renderer.setAttribute('exportparts', 'head,foot,filter')
this.renderer.addEventListener('load', e => this.#onLoad(e.detail)) this.renderer.addEventListener('load', e => this.#onLoad(e.detail))
this.renderer.addEventListener('relocate', e => this.#onRelocate(e.detail)) this.renderer.addEventListener('relocate', e => this.#onRelocate(e.detail))
this.renderer.addEventListener('snapend', () =>
this.history.replaceState(this.lastLocation))
this.renderer.addEventListener('create-overlayer', e => this.renderer.addEventListener('create-overlayer', e =>
e.detail.attach(this.#createOverlayer(e.detail))) e.detail.attach(this.#createOverlayer(e.detail)))
this.renderer.open(book) this.renderer.open(book)