Skip to content

Let a gesture area's pan trigger when let go far enough - #651

Merged
simonhamp merged 1 commit into
mainfrom
feat/gesture-area-trigger
Nov 3, 2026
Merged

simonhamp merged 1 commit into
mainfrom
feat/gesture-area-trigger

Conversation

@simonhamp

@simonhamp simonhamp commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Adds trigger-x / trigger-y and @trigger to native:gesture-area, for a pull that does something when you let go far enough. It's the swipe-to-reply pattern: the row follows the finger one way, the phone buzzes once it's far enough, letting go there acts, and the row springs back either way.

<native:gesture-area :pan-x="$dx" trigger-x="-64" @trigger="reply(5)">
    <native:row :translate-x="$dx">…</native:row>
    <native:icon … :opacity="$dx->interpolate([-64, 0], [1, 0])" />
</native:gesture-area>

Snap points couldn't do this. They settle the row open, and PHP only hears where it settled once the finger lifts, so a haptic at the point would have needed a round trip per frame.

The distance is measured from where the pan rests, and its sign is the way the pull goes. It goes out as pan-x-trigger / pan-y-trigger, and replaces any snap points on that axis. @trigger registers on_trigger, which rides the PRESS event with no payload, so dispatch needed nothing new. trigger joins the precompiler's core events and the collector's handlers.

Native::test() gets trigger($target), which fires it by method or ref the way dragEnd() does.

The renderers are in NativePHP/mobile-ui#197. The class docblock describes the attributes.

Tests cover the props (left off with no pan or a zero distance, and replacing snap points), the Blade path, the precompiler and the test harness. The full suite passes.

Used by NativePHP/dev-null-app#157.

🤖 Generated with Claude Code

…trigger)

A swipe-to-reply needs a pull that follows the finger one way, buzzes
once it's far enough, acts if let go there and springs back either way.
Snap points can't do it: they settle the row open, and PHP only hears
where it settled after the finger lifts.

trigger-x / trigger-y set how far from rest a pull on a bound pan axis
goes to trigger, the sign giving the way. They go out as pan-x-trigger /
pan-y-trigger and take the place of snap points on that axis. @trigger
registers on_trigger, which rides the PRESS event with no payload. The
renderers are in NativePHP/mobile-ui.

Native::test() gets trigger($target) to fire it by method or ref.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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