Skip to content

feat(reader): open image gallery & table zoom on single tap - #4600

Merged
chrox merged 2 commits into
mainfrom
feat/tap-to-open-image-table
Jun 16, 2026
Merged

feat(reader): open image gallery & table zoom on single tap#4600
chrox merged 2 commits into
mainfrom
feat/tap-to-open-image-table

Conversation

@chrox

@chrox chrox commented Jun 16, 2026

Copy link
Copy Markdown
Member

What & why

Today the image gallery (ImageViewer) and table zoom (TableViewer) can only
be 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

  • Reflowable EPUB — tap an <img> / <svg>-with-<image> opens the image
    gallery; tap a <table> opens the table zoom.
  • Fixed-layout (PDF / comics / manga) — unchanged: a tap still turns the page
    (there the tap is the page-turn gesture).
  • Long-press — unchanged in all book types.
  • Linked image (image inside <a>) — unchanged: the tap follows the link.
  • Drag / long-hold / double-tap — unchanged: the new branch sits after the
    existing link/footnote/drag/long-hold/Word-Wise guards and rides the 250ms
    double-click deferral, so it can't double-trigger.

Implementation

  • Reuses the existing iframe-long-pressuseLongPressEvent
    handleImagePress / handleTablePress flow; no new message type or consumer.
  • New shared detectMediaTarget() helper resolves an element to the viewer
    payload; both the long-press path and the new tap path use it so they can't
    drift.
  • handleClick gains an isFixedLayout flag (passed from FoliateViewer via
    bookData.isFixedLayout) to gate the tap-to-open branch.

Testing

  • pnpm test — full suite green (5644 passed). New cases in
    iframeEventHandlers.test.ts: reflowable image-tap and table-tap post
    iframe-long-press; fixed-layout image-tap still posts iframe-single-click;
    linked-image tap posts neither; existing double-click / long-hold tests pass.
  • pnpm lint (tsgo + biome) — clean.

Note: this does not claim to fix the underlying #4584 tap-death (unreproduced,
likely WebView-148-specific); it gives an independent entry path.

🤖 Generated with Claude Code

chrox and others added 2 commits June 16, 2026 12:02
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>
@chrox
chrox merged commit e145eb8 into main Jun 16, 2026
11 checks passed
@chrox
chrox deleted the feat/tap-to-open-image-table branch June 16, 2026 04:58
dalzyu added a commit to dalzyu/readest-hermes that referenced this pull request Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant