From 851d873f76287b2296a970bea773c1df9300c805 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Thu, 19 Nov 2026 16:41:15 +1100 Subject: [PATCH 1/2] feat(staged): pinch to open and close note images on mobile web A pinch-out on an inline note or chat image now opens it in the full screen viewer, and a pinch-in from the fitted size closes it. Both follow the fingers: the picture moves between its place in the note and the fit while the viewer's backdrop and header fade with the gesture. Opening. A recogniser on the markdown container (mediaPinch.ts) takes two-finger touches where at least one finger is on an image. It prevents the moves and Safari's gesture events, so the page no longer zooms and a pinch-in no longer opens the tab overview. Once the fingers spread it mounts the viewer with the picture laid exactly over the inline image and feeds it the gesture through a new programmatic setTransform on the zoom controller. The dialog's slide animation is off on this path. On release the viewer settles at the fit, or returns the picture to the note when the pinch was let go early. Closing. The zoom controller gains an opt-in pinchDismiss option. A touch gesture that starts at the fit may go below it, unconstrained, reporting progress; on release it closes past a threshold (or on a quick pinch) and springs back to the fit otherwise. A gesture that starts zoomed in stops at the fit and never closes, so zooming back out cannot overshoot into a close. With nowhere to return to (the inline image is out of view) the picture shrinks about its centre and fades. Only the image viewer turns the option on; the diagram viewer and the wheel behaviour are unchanged. Tap and the expand button still open the viewer with the usual animation. The research note suggested `touch-action: pan-x pan-y` on the figure. It is deliberately not used: in Mobile Safari on the iOS 27.2 simulator it stopped a one-finger drag that starts on the image from scrolling the note, and preventing the events is enough to hold page zoom at 1.00x. Signed-off-by: Matt Toohey Co-Authored-By: Claude Fable 5.2 --- .../ui/dialog/dialog-content.svelte | 5 +- .../src/lib/features/notes/NoteModal.svelte | 16 +- .../features/sessions/SessionChatPane.svelte | 16 +- .../shared/markdown/MediaViewerModal.svelte | 219 +++++++++++- .../lib/shared/markdown/diagramZoom.test.ts | 126 +++++++ .../src/lib/shared/markdown/diagramZoom.ts | 98 +++++- .../lib/shared/markdown/mediaPinch.test.ts | 316 ++++++++++++++++++ .../src/lib/shared/markdown/mediaPinch.ts | 313 +++++++++++++++++ .../src/lib/shared/markdown/mediaViewer.ts | 16 +- 9 files changed, 1104 insertions(+), 21 deletions(-) create mode 100644 apps/staged/src/lib/shared/markdown/mediaPinch.test.ts create mode 100644 apps/staged/src/lib/shared/markdown/mediaPinch.ts diff --git a/apps/staged/src/lib/components/ui/dialog/dialog-content.svelte b/apps/staged/src/lib/components/ui/dialog/dialog-content.svelte index 7c68504d3..611a0087b 100644 --- a/apps/staged/src/lib/components/ui/dialog/dialog-content.svelte +++ b/apps/staged/src/lib/components/ui/dialog/dialog-content.svelte @@ -23,6 +23,7 @@ class: className, style: styleProp, portalProps, + overlayProps, children, showCloseButton = true, fullScreenOnMobile = true, @@ -35,6 +36,8 @@ ...restProps }: WithoutChildrenOrChild & { portalProps?: WithoutChildrenOrChild>; + /** For a dialog that drives its own backdrop, such as a gesture-tracked open. */ + overlayProps?: ComponentProps; children: Snippet; showCloseButton?: boolean; fullScreenOnMobile?: boolean; @@ -264,7 +267,7 @@ - +