feat(reader): open image gallery & table zoom on single tap - #4600
Merged
Conversation
In reflowable EPUBs, a single tap on an image or table now opens the same viewer a long-press opens, so the image gallery / table zoom is reachable by both gestures. Fixed-layout books (PDF/comics/manga) keep tap-to-turn, and long-press is unchanged everywhere. Reuses the existing iframe-long-press -> handleImagePress/handleTablePress flow via a new shared detectMediaTarget() helper (also adopted by the long-press path so the two entry points can't drift). handleClick now takes an isFixedLayout flag; the tap branch sits after the link/footnote/drag/ long-hold/Word-Wise guards so linked images still follow links and a long-hold or double-tap won't double-trigger. Context: #4584 (single taps stop registering after picture zoom on some WebView builds) - this adds a second, independent way into the viewer rather than fixing that root cause. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The message is now posted for both a long-press (any book) and a single tap on an image/table (reflowable books), so the long-press-specific name was misleading. Rename the message type to `iframe-open-media` and the consumer hook `useLongPressEvent` -> `useOpenMediaEvent`. The long-press detector (`addLongPressListeners`/`handleLongPress`) keeps its name since it still detects a long-press specifically. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dalzyu
added a commit
to dalzyu/readest-hermes
that referenced
this pull request
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Today the image gallery (
ImageViewer) and table zoom (TableViewer) can onlybe opened by long-pressing the image / table. This adds a second, equivalent
way in: in reflowable EPUBs, a single tap on an image or table opens the
same viewer. Long-press is unchanged and keeps working everywhere.
This is motivated by #4584, where single taps stop registering after using
picture zoom on some Android WebView builds (long-press still works). Rather than
chase that elusive, WebView-version-specific root cause, this makes the feature
reachable by both gestures so users aren't dependent on a single input path.
Behavior
<img>/<svg>-with-<image>opens the imagegallery; tap a
<table>opens the table zoom.(there the tap is the page-turn gesture).
<a>) — unchanged: the tap follows the link.existing link/footnote/drag/long-hold/Word-Wise guards and rides the 250ms
double-click deferral, so it can't double-trigger.
Implementation
iframe-long-press→useLongPressEvent→handleImagePress/handleTablePressflow; no new message type or consumer.detectMediaTarget()helper resolves an element to the viewerpayload; both the long-press path and the new tap path use it so they can't
drift.
handleClickgains anisFixedLayoutflag (passed fromFoliateViewerviabookData.isFixedLayout) to gate the tap-to-open branch.Testing
pnpm test— full suite green (5644 passed). New cases iniframeEventHandlers.test.ts: reflowable image-tap and table-tap postiframe-long-press; fixed-layout image-tap still postsiframe-single-click;linked-image tap posts neither; existing double-click / long-hold tests pass.
pnpm lint(tsgo + biome) — clean.🤖 Generated with Claude Code