Gesture lifecycle
The states a gesture moves through, the callbacks that mark each step, and GestureStateManager for changing state from a callback. import { GestureState, GestureStateManager } from '@blotch/angular-lynx';
Usage
Every callback gets the event and a GestureStateManager for that gesture on that element.
States
The event's state field is usually absent. The callback that fires tells you the step.
Callbacks
A successful tap runs onStart, then onEnd. A long press runs onStart once the hold is long enough, and onEnd when the finger lifts.
Failed and canceled gestures
There's no onFail or onCancel callback.
- Tap and long press: Lynx also calls
onEndwhen the gesture fails. AngularLynx drops that call, soonEndfires only afteronStart. Use either one to mean "it happened". - Pan, Fling, Pinch and Rotation: AngularLynx passes
onEndthrough as Lynx sends it. Don't assume a pan'sonEndmeans success. Check your own state instead. - Continuous gestures need
onBegin. Lynx fires theironStartandonEndonly afteronBegin, so register one, even an empty one.
Callback signature
TEvent is the gesture's event type, such as PanGestureEvent (see Gesture types). Callbacks run on the main thread, inside the native gesture. Setting signals there is safe, but don't add or remove elements until the gesture ends (see the setTimeout rule).
API
GestureStateManager is the second argument of every callback. You don't create one yourself.
activate()
Moves the gesture to ACTIVE now, without waiting for its own conditions, such as minDistance. Use it in onBegin or onUpdate once your own check passes.
fail()
Moves the gesture to FAILED, so it stops tracking this touch. Gestures that waitFor it can then activate, and a parent scroll view can take the touch.
end()
Moves an active gesture to END, as if the finger had lifted. Use it to stop a drag at a limit, for example.
consumeGesture(consume?)
Keeps this gesture from reaching the element's ancestors. Their gestures and scroll views don't respond to the touch as well. Call consumeGesture(false) to let them respond again.
interceptGesture(intercept?)
The opposite direction: claims the touch from the element's descendants, before they handle it. Use it on a parent, such as a pull-to-refresh container that takes over its list's scroll. Call interceptGesture(false) to release it.
