Fix page getting stuck in Foliate GTK

This commit is contained in:
John Factotum
2023-05-18 23:41:26 +08:00
parent 7e618eb2b1
commit fb95b70c8e
+8
View File
@@ -607,6 +607,13 @@ export class Paginator extends HTMLElement {
// FIXME: vertical-rl only, not -lr // FIXME: vertical-rl only, not -lr
if (this.scrolled && this.#vertical) offset = -offset if (this.scrolled && this.#vertical) offset = -offset
if (smooth && this.pageAnimation) return new Promise((resolve, reject) => { if (smooth && this.pageAnimation) return new Promise((resolve, reject) => {
// `requestAnimationFrame` fixes the whole page getting "stuck" when
// transitioning chapters in Foliate (the GTK 4 app).
// It happens often but not always, and resolves itself after
// interacting with the page (e.g. clicking on it).
// IDK what causes it and I can't reproduce it in any other browser
// or even with a WebKitGTK WebView, but this trick seems to fix it
requestAnimationFrame(() => {
try { try {
const onScroll = () => { const onScroll = () => {
if (Math.abs(element[scrollProp] - offset) > 2) return if (Math.abs(element[scrollProp] - offset) > 2) return
@@ -621,6 +628,7 @@ export class Paginator extends HTMLElement {
reject(e) reject(e)
} }
}) })
})
else { else {
element[scrollProp] = offset element[scrollProp] = offset
this.#afterScroll(reason) this.#afterScroll(reason)