Skip to content

Commit 88ade41

Browse files
authored
Merge pull request #214 from codedogQBY/perf/instant-page-turn
perf(reader): instant page turn — disable animation + reduce chapter switch delay
2 parents f5b95c8 + fa75d30 commit 88ade41

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/app/src/components/reader/FoliateViewer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,8 +2257,8 @@ function applyRendererSettings(
22572257
applyReflowLayoutSettings(view, settings);
22582258
}
22592259

2260-
// Enable page turn animation
2261-
renderer.setAttribute("animated", "");
2260+
// Disable page turn animation for instant response
2261+
// renderer.setAttribute("animated", "");
22622262

22632263
// Apply CSS styles (skip font overrides for fixed layout)
22642264
applyRendererStyles(view, settings, isFixedLayout, theme);

packages/foliate-js/paginator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ export class Paginator extends HTMLElement {
939939
// FIXME: vertical-rl only, not -lr
940940
if (this.scrolled && this.#vertical) offset = -offset;
941941
if ((reason === "snap" || smooth) && this.hasAttribute("animated"))
942-
return animate(element[scrollProp], offset, 400, easeOutCubic, (x) => (element[scrollProp] = x)).then(() => {
942+
return animate(element[scrollProp], offset, 250, easeOutCubic, (x) => (element[scrollProp] = x)).then(() => {
943943
this.#scrollBounds = [offset, this.atStart ? 0 : size, this.atEnd ? 0 : size];
944944
this.#afterScroll(reason);
945945
});
@@ -1113,7 +1113,7 @@ export class Paginator extends HTMLElement {
11131113
index: this.#adjacentIndex(dir),
11141114
anchor: prev ? () => 1 : () => 0,
11151115
});
1116-
if (shouldGo || !this.hasAttribute("animated")) await wait(100);
1116+
if (shouldGo || !this.hasAttribute("animated")) await wait(16);
11171117
this.#locked = false;
11181118
}
11191119
prev(distance) {

0 commit comments

Comments
 (0)