Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6903677
fix: keep page swipes continuous across chapters and PDFs
Eoic Nov 14, 2026
6dbff6f
fix: retain PDF rendering through swipe settlement
Eoic Nov 14, 2026
e5a13fa
fix: allow interruptible PDF swipes and defer cache work
Eoic Nov 14, 2026
cba0139
fix: keep desktop PDF mouse swipes interruptible
Eoic Nov 14, 2026
a00fcb3
feat: support mouse page drags in text book formats
Eoic Nov 14, 2026
57a8375
fix: accept EPUB mouse swipes from outer window margins
Eoic Nov 14, 2026
2602f5d
feat: turn paginated books instantly with the scroll wheel
Eoic Nov 14, 2026
9fd9eef
fix: turn zoomed PDF pages at scroll boundaries
Eoic Nov 14, 2026
cae0fce
fix: allow mouse page swipes in zoomed PDFs
Eoic Nov 14, 2026
cf3cdae
ui: show page appearance before link highlighting
Eoic Nov 14, 2026
dc59aad
ui: choose page appearance from a dropdown
Eoic Nov 14, 2026
5bddd3b
fix: repair continuous EPUB layout and chapter scrolling
Eoic Nov 14, 2026
c01f6ab
fix: cross continuous EPUB chapter edges with touch
Eoic Nov 14, 2026
0d65af2
fix: preserve reader gestures with custom renderers and reduced motion
Eoic Nov 14, 2026
f389b7f
test: observe PDF controls after selection before checking zoom
Eoic Nov 14, 2026
3f7c8a7
fix: ignore clipped EPUB text when starting margin drags
Eoic Nov 14, 2026
5aea0a0
fix: prevent decelerating mouse turns from flinging backwards
Eoic Nov 14, 2026
c2bb9d7
fix: preserve PDF swipe direction when releasing moving pages
Eoic Nov 14, 2026
d52e5f4
test: keep format mouse swipes within one page of travel
Eoic Nov 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ view center survive viewport/layout changes; fit modes adapt to the available
space. Paginated slots isolate spreads even when zoomed out. pdfrx owns rendering,
selection, and bounded text search. `PdfReaderTools` exposes zoom, fit, page entry,
search, and a bounded return history to the shell without exposing PDFium types.
Each paginated spread retains its viewer and rendered images through a swipe and
settlement. Neighboring viewers mount lazily and release their resources when
evicted from the page cache. Search results belong to the document; navigation and
keyboard focus follow the active spread.
Speculative viewers initialize while paging is stationary; visible destinations
can load immediately. Paginated viewers share layout until viewport or page
dimensions change, and preview images use stable resolution steps sized for the
screen, up to the renderer's one-pass limit. Holding an in-flight turn does not
commit or snap its location. Horizontal mouse drags turn pages at custom zoom,
while vertical drags pan and text drags select. During a mouse turn the PDF keeps
its horizontal position inside the moving spread; the viewer does not also pan.
Zoomed touch gestures retain document panning and pinch zoom. With animation disabled
or reduced motion enabled, mouse turns commit instantly on release.

The host persists the synchronized locator separately from `PdfViewState`, which
is device-local view configuration. `ReaderDocument.initialPdfView` and
Expand All @@ -89,6 +102,25 @@ Controls and panels overlay the reading viewport so visibility changes do not
repaginate content. Page-tap toggles exclude selections, links and competing
pointer gestures. Keyboard focus survives chapter replacement without stealing
focus from an open panel. Reduced motion changes transitions, not layout.
In paginated text formats, mouse drags starting in blank space, including the
outer window margins, turn pages;
drags starting on rendered text remain selection gestures. Mouse turns use the
same page controller as touch and can interrupt an unfinished turn.
Wheel input turns paginated pages immediately without changing the animation
preference. Small nonzero deltas count as a turn; same-direction bursts are
limited to one turn per 120 ms, while reversing direction responds immediately.
Zoomed PDFs pan within the current spread; scrolling outward at its top or bottom
turns the page without animation. Forward turns open at the top, backward turns
at the bottom, preserving zoom. Horizontal zoomed panning, continuous readers,
and modifier-key zoom retain native wheel input.
Continuous EPUB uses a full-width scroll surface with centered text and a viewport-edge
scrollbar. Its chunk extents use the rendered fragment heights, including text reshaping
at paragraph cuts. Outward wheel input at a chapter edge opens the adjacent chapter;
backward navigation restores its bottom. Touch drags can reach and continue beyond
an edge in one gesture, including under bouncing physics. Only a completed,
unselected single-touch gesture commits the adjacent chapter; inertial scrolling
and cancelled gestures do not trigger a chapter turn. Custom scrolling renderers
share the same chapter boundary gestures.

Internal presentation modules are not public API. Host customization uses
`ReaderUiBuilders` and exported builder contexts. A `compactPanelRoute` factory
Expand Down
1 change: 1 addition & 0 deletions lib/src/engine/epub/epub_content_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ final class FlutterHtmlEpubContentRenderer implements EpubContentRenderer {
return ColoredBox(
color: preferences.backgroundColor,
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: controller,
padding: preferences.pageMargins,
child: DefaultTextStyle(
Expand Down
14 changes: 7 additions & 7 deletions lib/src/engine/epub/epub_reader_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ final class EpubReaderEngine extends ReaderEngine {

/// The viewport owns page turns, including transitions across spine items.
/// The engine handles boundaries when no paginated viewport is mounted.
Future<bool> Function(int direction)? moveViewport;
Future<bool> Function(int direction, {required bool animate})? moveViewport;

String get currentChapterHtml => _currentChapterHtml;
List<EpubContentBlock> get blocks => _blocks;
Expand Down Expand Up @@ -385,12 +385,12 @@ final class EpubReaderEngine extends ReaderEngine {
}

@override
Future<void> goNext() => _queueTurn(1);
Future<void> goNext() => turnPage(1);
@override
Future<void> goPrevious() => _queueTurn(-1);
Future<void> goPrevious() => turnPage(-1);

Future<void> _queueTurn(int direction) {
final turn = _turnQueue.then((_) => _move(direction));
Future<void> turnPage(int direction, {bool animate = true}) {
final turn = _turnQueue.then((_) => _move(direction, animate: animate));
_turnQueue = turn.catchError((Object _) {});
return turn;
}
Expand Down Expand Up @@ -446,14 +446,14 @@ final class EpubReaderEngine extends ReaderEngine {
return chapter;
}

Future<void> _move(int direction) async {
Future<void> _move(int direction, {required bool animate}) async {
if (_locator == null) {
throw const ReaderException(
ReaderErrorCode.engineUnavailable,
'No EPUB document is loaded.',
);
}
if (await moveViewport?.call(direction) ?? false) return;
if (await moveViewport?.call(direction, animate: animate) ?? false) return;
final index = _locator!.spineIndex + direction;
if (index < 0 || index >= _chapterCount) {
throw const ReaderException(
Expand Down
28 changes: 22 additions & 6 deletions lib/src/engine/epub/epub_rich_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/widgets.dart';
import 'package:flutter/rendering.dart';

import '../../domain/reader_preferences.dart';
import '../../domain/reader_types.dart';
import '../../domain/reader_selection.dart';
import '../../domain/reader_locator.dart';
import '../../presentation/reader_interaction_scope.dart';
Expand Down Expand Up @@ -224,6 +225,25 @@ Stream<EpubRichPage> paginateEpub(
textDirection: direction,
textScaler: textScaler,
)..layout(maxWidth: width);
EpubPageFragment fragment(int start, int end, double height) {
if (preferences.layoutMode != ReaderLayoutMode.scroll) {
return EpubPageFragment(block, start, end, height);
}
// A split paragraph is laid out as a new Text widget. Its final newline
// or reshaped runs can add a line that was absent from the original cut.
// Scroll extents must describe that rendered fragment, not the estimate.
final measured = TextPainter(
text: block.span(preferences, start: start, end: end),
textDirection: direction,
textScaler: textScaler,
)..layout(maxWidth: width);
try {
return EpubPageFragment(block, start, end, measured.height);
} finally {
measured.dispose();
}
}

try {
final lines = painter.computeLineMetrics();
final text = span.toPlainText();
Expand Down Expand Up @@ -253,9 +273,7 @@ Stream<EpubRichPage> paginateEpub(
)
.start;
if (boundary > start) {
fragments.add(
EpubPageFragment(block, start, boundary, segmentHeight),
);
fragments.add(fragment(start, boundary, segmentHeight));
start = boundary;
}
if (fragments.isNotEmpty) {
Expand All @@ -267,9 +285,7 @@ Stream<EpubRichPage> paginateEpub(
segmentHeight += lineHeight;
}
if (start < text.length) {
fragments.add(
EpubPageFragment(block, start, text.length, segmentHeight),
);
fragments.add(fragment(start, text.length, segmentHeight));
used += segmentHeight + spacing;
}
} finally {
Expand Down
Loading
Loading