Skip to content

feat: pinch, pan and double-tap zoom on opened media - #557

Merged
vaakx-dev merged 1 commit into
mainfrom
sand/image-html-pinch-zoom
Nov 24, 2026
Merged

vaakx-dev merged 1 commit into
mainfrom
sand/image-html-pinch-zoom

Conversation

@vaakx-dev

Copy link
Copy Markdown
Owner

Pinch, pan and double-tap zoom for images in the viewer and for full-screen HTML pages, on phones and in the Android app.

What

  • New shared gesture in the kit (gesture/zoom.ts): two-finger pinch around the pinch point, double-tap, and wheel zoom (any wheel, or only Ctrl+wheel and trackpad pinch where the wheel scrolls). Taps on links, buttons and fields don't count toward a double-tap.
  • Image viewer: pinch and double-tap zoom around the finger, one-finger pan while zoomed, wheel zooms at the cursor, double-click still toggles. Swiping to the next image only works at fit, as before. Bounds stay 1× to 8×.
  • Kit zoom stage (full-screen HTML pages and Mermaid diagrams): pinch, double-tap and Ctrl+wheel zoom keep the point under the fingers in place by moving the stage scroll. One-finger pan is the stage's own scrolling. Bounds stay 25% to 400%.
  • HTML frame: when the host says the page is zoomable (full screen only), the page relays pinches, double-taps and Ctrl+wheel to the host (sand/zoomable, sand/zoom-by, sand/zoom-toggle). The host checks the messages and maps frame points to the screen. Inline pages in the chat keep the old behavior.
  • Phone test plugins/ui/chat/html/test/web/zoom.ts, added to test:phone.

Why

  • Pinch did nothing in the Android app. Its WebView has page zoom off, which keeps the chat unzoomed, so opened content needs its own zoom.
  • Taking over two-finger moves and double-taps keeps the browser from zooming the whole app in mobile Chrome.
  • Open viewers and sheets already stop sand's sidebar and back swipes. The new test checks that this still holds while zoomed.

Verification

  • bun test plugins/ui/chat/html/test/web/zoom.ts at 390×844 with touch, using real multi-touch through CDP:
    • Full-screen page: a pinch zooms past twice the fit level and keeps the pinch point within 4px. A one-finger drag pans the stage, a swipe right from the left side pans back and leaves the sheet and sidebar alone, and a double-tap returns to Fit.
    • Image opened from the page: a pinch at an off-center point zooms past 3× and keeps that point within 4px. A drag pans without closing or opening the sidebar, and a double-tap resets scale and offset.
    • With the gesture unhooked, both tests fail.
  • bunx tsc, vrui-check, scripts/deps.ts, scripts/comments.ts, bun test for kit, html and images, and the kit gallery phone test all pass.
  • Not covered by automated tests: desktop Ctrl+wheel and trackpad pinch, and a real Android phone.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Performance: ✅ every row is within its limit

Main d895e07 against this PR 352736a, both measured in the same job, medians of 5 runs. Times, memory and CPU fail when the PR is more than 15% worse, bytes when they grow more than 5%; changes under 20 ms or 2 KB never fail. Logs

main PR change
Phone (4× slower CPU, 150 ms, 9 Mbit/s link)
open a chat: shows 269 ms 274 ms +1.9% ✅
open a chat: usable 293 ms 283 ms -3.3% ✅
first visit with an empty cache: usable 1.80 s 1.81 s +0.4% ✅
open a long chat: usable 288 ms 284 ms -1.1% ✅
send: your message shows 56 ms 53 ms -5.4% ✅
send: first reply text shows 292 ms 281 ms -4.0% ✅
main thread blocked over these steps 444 ms 442 ms -0.5% ✅
data on first visit 927.0 KB 928.3 KB +0.1% ✅
data per chat opened 49.5 KB 49.5 KB -0.0% ✅
data while idle for 20 s 220 B 220 B 0% ✅
app code a phone downloads 1.6 MB 1.6 MB +0.2% ✅
Main pages (same phone and link)
Settings: time to open 78 ms 81 ms +3.5% ✅
Settings: data to open 0 B 0 B 0% ✅
Settings: data per minute left open 600 B 600 B 0% ✅
Add-ons: time to open 97 ms 90 ms -6.9% ✅
Add-ons: data to open 100 B 100 B 0% ✅
Add-ons: data per minute left open 600 B 600 B 0% ✅
Usage: time to open 65 ms 70 ms +7.2% ✅
Usage: data to open 14.8 KB 14.8 KB 0% ✅
Usage: data per minute left open 600 B 600 B 0% ✅
Search: time to open 70 ms 69 ms -1.6% ✅
Search: data to open 0 B 0 B 0% ✅
Search: data per minute left open 600 B 600 B 0% ✅
Performance: time to open 442 ms 441 ms -0.2% ✅
Performance: data to open 846 B 886 B +4.7% ✅
Performance: data per minute left open 2.0 KB 1.9 KB -5.8% ✅
PC side
start-up until ready 3.92 s 3.91 s -0.2% ✅
memory while idle 236.9 MB 237.2 MB +0.1% ✅
CPU used over 60 s idle 350 ms 360 ms +2.9% ✅
memory after 100 scripted chat turns 273.9 MB 273.8 MB -0.0% ✅
CPU for one reply 47 ms 46 ms -2.1% ✅
search time on 100k messages 105 ms 104 ms -0.9% ✅
database size per 10k messages 19.8 MB 19.8 MB -0.0% ✅
worktree list with sizes on 40 worktrees 577 ms 594 ms +2.8% ✅
slowest other reply during a worktree list 45 ms 53 ms +18.7% ✅

@vaakx-dev
vaakx-dev force-pushed the sand/image-html-pinch-zoom branch from 6e3bf1b to 4ecf330 Compare November 24, 2026 13:34
Images in the viewer and full-screen HTML pages now zoom with two fingers around the pinch point, pan with one finger while zoomed, and double-tap between fit and a closer look. Ctrl+wheel and trackpad pinch zoom pages on desktop; the wheel keeps zooming images. A page inside the sandboxed frame relays its pinches to the host, so the frame keeps its own scrolling and taps.
@vaakx-dev
vaakx-dev force-pushed the sand/image-html-pinch-zoom branch from 4ecf330 to 352736a Compare November 24, 2026 13:44
@vaakx-dev
vaakx-dev merged commit 3b5bfc8 into main Nov 24, 2026
18 of 19 checks passed
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