Repository navigation
Double tap to zoom a gesture area, glide after a drag, and hand drags it can't use to its parent - #220
Open
simonhamp wants to merge 3 commits into
Open
Double tap to zoom a gesture area, glide after a drag, and hand drags it can't use to its parent#220simonhamp wants to merge 3 commits into
simonhamp wants to merge 3 commits into
Conversation
A gesture area with double-tap-zoom zooms its pinch to that scale on a double tap, bringing the tapped point to the middle as far as bounded lets the pan go. A double tap on content that's already zoomed goes back to 1. Both animate like the spring back, and on_pinch_end reports the new scale once the zoom lands, so a screen that tracks the zoom from its pinches hears this one too. Aiming a zoom moves the pan. A photo pager only binds pan-x and pan-y once the picture is zoomed, because a bound pan takes every drag and the pager would stop paging. zoom-pan-x and zoom-pan-y give the pinch and the double tap those values without taking any drags, so a double tap at whole size can aim, and a first pinch now zooms around the fingers too. The double tap cancels and consumes nothing, so pinches, pans, pagers and an outer drag to close keep working. On iOS a tap ends a zero-length drag when the pan is bound, which used to restart the spring back; it now leaves a settle alone when nothing is out of place, or it would stop the zoom the second tap just started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp
added a commit
to NativePHP/dev-null-app
that referenced
this pull request
Nov 18, 2026
A double tap on an image at its whole size zooms to half the most it
zooms (twice), with the tapped point brought to the middle as far as the
picture's bounds allow. A double tap on a zoomed image goes back to its
whole size. Both animate on the phone and report through the same
@pinchEnd as a pinch, so the pans bind and let go as before.
The viewer no longer slides up. The black fades in over the screen while
the tapped picture grows out of its thumbnail into place, and closing
runs that backwards. After paging, it shrinks into the thumbnail of the
image it's showing. With no thumbnail on screen it only fades. Each
commit image now has a ref of its own (thumb-{id}) for this, beside the
pressable's, and showImagesInViewer() takes those refs.
Every page also hands its pans to the zoom as zoom-pan, which takes no
drags. That's what lets a double tap at whole size aim, and it means the
first pinch now zooms around the fingers rather than the middle.
This needs NativePHP/mobile-ui#220 and #221 and NativePHP/mobile-air#716.
Until they're in, mobile-ui ignores the new attributes: the viewer slides
up as before and a double tap does nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 18, 2026
simonhamp
marked this pull request as ready for review
November 19, 2026 22:23
…ound it A bounded area with its pans bound used to take every one-finger drag, so a photo pager had to unbind the pans at whole size and rebind them from PHP after each zoom, and #220 added zoom-pan-x/y so the zoom could still aim. Now the renderer decides: the area takes a drag only while the zoomed content has more than 2pt of room on a bound axis. At whole size the drag goes to the pager, the drag to close or the scroll view around it. Zoomed in, the photo pans and they stay still. zoom-pan-x/y are gone; the pinch and the double tap move the bound pans. iOS: bounded areas use a UIKit pan that decides in gestureRecognizerShouldBegin from the live zoom. Scroll view pans, an enclosing area's one-axis pan and the iOS 26 swipe back wait for it. Android: the bounded drag judges room once at touch slop and otherwise leaves the drag unconsumed. Once a parent has it, only a second finger (a pinch) takes it back. Compose's slop helper re-judged fast drags on every event and could grab a page swipe back mid-flight, so this uses its own small loop. Fixed on the way, all found on devices: - iOS: the finger left after a pinch couldn't pan until both lifted. - iOS: picking up content a pinch left past an edge jumped it inward. - Android: the first pinch after a double tap started from the old scale. - Both: a swipe during a double tap's zoom-out stopped the zoom part way and left the photo zoomed. While that zoom runs, room is judged at the smaller of the live scale and where the zoom is heading. GestureAreaBoundedPanTest covers paging and closing at whole size, panning when zoomed, 1.01x still paging, the zoom-out swipe, a pinch after a double tap and a second finger landing mid-page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp
added a commit
to NativePHP/mobile-air
that referenced
this pull request
Nov 20, 2026
The renderers (NativePHP/mobile-ui#220) now give a bounded area a one-finger drag only while its zoomed content has room to move, so a photo pager can keep pan-x/pan-y bound all the time. The pinch and @doubleTap.zoom aim with those pans, which makes zoom-pan-x/y and switching the pans from PHP unnecessary. The docblock says how drags are taken and the pager example binds the pans directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp
added a commit
to NativePHP/dev-null-app
that referenced
this pull request
Nov 20, 2026
With NativePHP/mobile-ui#220 and NativePHP/mobile-air#716, a bounded gesture area only takes a one-finger drag while its zoomed image has room to move, so at whole size the pager pages and the drag to close closes with the pans bound. Each page now binds its pans all the time. $viewerZoomed, viewerZoomEnded(), ImageViewer::ZoomedPast, @pinchEnd, zoom-pan and the swapped close area are gone. This needs those two PRs: without them a bound pan takes every drag, so the pager wouldn't page and the drag to close wouldn't close. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A bounded drag now carries on at the finger's speed when it lifts, slowing to a stop and bouncing off an edge it reaches, the way a scroll view does. A finger held still before it lifts doesn't glide. on_drag_end reports where the content will come to rest. Zoomed content that reaches its edge part way through a drag hands the rest of the drag to the pager or scroll view around it, so the next photo slides in as Photos does, and a flick from there pages. On Android this goes through nested scrolling, and the pager settles a handed-off drag by its own position and the flick, since Compose's would decide by how far the finger went. On iOS the drag moves the enclosing scroll view itself. Whether a drag is the area's now depends on its direction too: a zoomed photo at its right edge leaves a swipe left to the pager. Zoomed content keeps drags from a gesture area's pan around it though, so a drag to close only works at whole size. A bounded area clips its content, so a zoomed photo no longer draws over Android's close row or onto the next page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp
added a commit
to NativePHP/mobile-air
that referenced
this pull request
Nov 20, 2026
Renderers in NativePHP/mobile-ui#220 now let zoomed content glide after a drag, hand a drag past its edge to the pager around it, and clip the content to the area. A drag to close only gets drags at whole size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp
added a commit
to NativePHP/dev-null-app
that referenced
this pull request
Nov 20, 2026
…e pager With NativePHP/mobile-ui#220's latest commit, a drag past a zoomed image's edge pulls the pager on to the next image, a drag that way at the edge pages, and a drag let go glides on. The drag to close still only gets drags at whole size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Renderers for NativePHP/mobile-air#716: double tap to zoom on
native:gesture-area, and a new rule for when aboundedarea takes a drag.In Blade the double tap is
@doubleTap.zoom="2"and the scale is:zoom(withzoom-min,zoom-maxand@zoomEnd). mobile-air turns those into the props read here:double-tap-zoom, and the samepinch-*keys as before.A bounded area only takes drags it can use
A bounded area with its pans bound used to take every one-finger drag. So a photo pager had to unbind the pans at whole size (or the pager couldn't page and the drag to close never closed) and rebind them from PHP after each zoom, and the first version of this PR added
zoom-pan-x/zoom-pan-yso the zoom could still aim.Now the area takes a drag only while the zoomed content has more than 2pt of room to move the way the finger is going, judged from the live zoom when the drag would start. At whole size the drag goes to whatever is around the area: a pager pages, a drag to close closes, a scroll view scrolls. Zoomed in, the photo pans and they stay still. A zoomed photo at its right edge leaves a swipe left to the pager. It keeps drags from a gesture area's pan around it, though, so a drag to close only works at whole size and panning a zoomed photo up to its edge doesn't start closing the viewer. A zoom that ends a hair past whole size (under about 1.01x on a phone) still counts as whole size.
zoom-pan-*is gone; the pinch and the double tap aim with the bound pans.gestureRecognizerShouldBegin. Scroll view pans, an enclosing area's one-axis pan and the iOS 26 swipe back wait for it. It runs alongside the pinch and the double tap, and picks the pans that wait out by what they are, since SwiftUI can host nested areas on one UIView.A drag past the edge pulls the pager on
When zoomed content reaches its edge part way through a drag, the rest of the drag moves the pager or scroll view around the area, so the next photo slides in the way it does in Photos. Going back the other way gives the pager its page back before the photo pans again. On release the pager goes on to the next page past halfway or with a flick that way, and back otherwise. With nothing around to take it, the content stretches past the edge and springs back as before.
setContentOffset(_:animated:).PagerHandOffin PagerRenderer) now settles that case itself by the pager's own position and the flick.Inertia
Let go of a bounded drag and the content glides on at the finger's speed, slowing at UIScrollView's normal rate, and bounces off an edge it reaches with a critically damped spring. Both platforms step the same exact solution per frame, so the frame rate doesn't change where it lands. A finger held still for 40ms before it lifts doesn't glide: neither platform sends moves while a finger is still, so both trackers would otherwise report the speed it last moved at.
on_drag_endfires on release with where the content will come to rest. A finger landing on gliding content stops it.Clipping
A bounded area clips its content, so a zoomed portrait photo no longer draws over the bottom of Android's close row, or onto the next page while paging.
Double tap to zoom
A double tap at whole size zooms to
double-tap-zoom, bringing the tapped point to the middle as far asboundedlets the pan go. A double tap past 1 goes back to 1 and the middle. It animates (0.35s, ease out), andon_pinch_endreports the new scale once it lands. iOS uses SwiftUI'sSpatialTapGesture(count: 2)as a simultaneous gesture. Android has its own small detector that consumes nothing.While that zoom is running, room is judged at the smaller of the live scale and where the zoom is heading. So a swipe during a zoom-out pages and the zoom still finishes. A swipe in the first frames of a zoom-in pages; once the zoom has real room, the drag pans and stops it where it is.
Fixed on the way, all found on devices
Behaviour changes worth knowing
on_drag_end) no longer takes drags.on_drag_end, as the one-axis pan already did.Testing
Android: new
GestureAreaBoundedPanTest, 24 cases, nine of them for the hand-off, the glide, the held-still release and the drag to close at a zoomed edge. The pager and the drag to close are stand-ins (HorizontalPageranddetectVerticalDragGestures), because the module'sNodeViewcan't hold a gesture area. The whole module passes (90). The cases for each fix fail without it.iOS:
swiftc -typecheck -wmoagainst mobile-air's NativeRender gives the same errors asmain(core types outside that folder), none in this file, with a canary to prove the file was compiled.Second round (glide, hand-off, clipping), same setup. On iOS, measured from screenshots: an 80pt flick glides the photo exactly to its edge, the same flick held still for 300ms stops where the finger did, a slow drag past the edge pulls the next image in (on video) and goes back on a held release short of halfway, a fast one pages, a drag out and back leaves the pager on its page and the photo where it started, a swipe at the edge pages, and a drag down on a zoomed photo stays with it while at whole size it closes. On Android the same, plus: the zoomed portrait photo stays below the close row, and at the last image a drag past the edge stretches and springs back. A fast drag past the edge was only checked on Android in Robolectric.
First round: the devnull image viewer (NativePHP/dev-null-app#175) with this branch and mobile-air#716 in
vendor, against a local API, on an iOS 27.0 iPhone 18 Pro simulator and an Android 35 emulator. Real double taps and pinches on both: the iOS Simulator tool's two-finger paths, and injected MotionEvents on Android. Checked:Not checked on iOS: lifting the first finger of a pinch and catching a spring back mid-flight, which the simulator tools can't do cleanly. Worth a try on a phone before merging.
🤖 Generated with Claude Code