mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Fix page getting stuck in Foliate GTK
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user