onPointerIntent
Tells a tap from a drag, and hover from touch, on one element: the pointer-event logic every
draggable or clickable widget rewrites. Press, then either release within threshold pixels
(onTap) or move past it (onDragStart, onDrag…, onDragEnd).
Only the first pointer that presses is followed (multi-touch ignores the others), and it is
captured with setPointerCapture so a drag keeps going outside the element — which means the
element receives the pointerup even when released elsewhere. Without pointer events (no
addEventListener on target), it does nothing and returns a function that does nothing.
Available since v3.1.8
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
target | Element | The element to listen on |
handlers | PointerIntentHandlers | What to do for each intent — see PointerIntentHandlers |
options | PointerIntentOptions | Threshold, button and cancellation — see PointerIntentOptions |
Returns
Section titled “Returns”function — A function that stops listening
Examples
Section titled “Examples”Tell a tap from a drag
Section titled “Tell a tap from a drag”A press released within the threshold is a tap; moving past it starts a drag.
Stop with an AbortSignal
Section titled “Stop with an AbortSignal”One abort() removes the listeners, as on unmount.
Related Types
Section titled “Related Types”PointerIntent
Section titled “PointerIntent”What a pointer is doing, passed to the handlers of onPointerIntent.
PointerIntentHandlers
Section titled “PointerIntentHandlers”Handlers for onPointerIntent; every one is optional.
PointerIntentOptions
Section titled “PointerIntentOptions”Options for onPointerIntent.
