Skip to content

Commit fa75d30

Browse files
bealqiuclaude
andcommitted
perf(reader): disable page turn animation + reduce chapter switch delay
- Remove 'animated' attribute from renderer so pages switch instantly instead of using a 400ms slide animation - Reduce cross-chapter wait from 100ms to 16ms (one frame) - Also reduce animation duration from 400ms to 250ms as fallback if animated is re-enabled in the future The combined effect makes page turning feel instant and responsive. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c182082 commit fa75d30

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
@@ -2239,8 +2239,8 @@ function applyRendererSettings(
22392239
applyReflowLayoutSettings(view, settings);
22402240
}
22412241

2242-
// Enable page turn animation
2243-
renderer.setAttribute("animated", "");
2242+
// Disable page turn animation for instant response
2243+
// renderer.setAttribute("animated", "");
22442244

22452245
// Apply CSS styles (skip font overrides for fixed layout)
22462246
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)