LongPressGestureHandler
A discrete gesture handler that activates when the corresponding view is pressed sufficiently long. When handler gets activated it will turn into END state when finger is released. The handler will fail to recognize if the finger is lifted before the minimum required time or if the finger is moved further than the allowable distance.
The handler is implemented using UILongPressGestureRecognizer on iOS and LongPressGestureHandler on Android.
Properties
See set of properties inherited from base handler class. Below is a list of properties specific to LongPressGestureHandler
component:
minDurationMs
How long the view has to be pressed in order for gesture to activate. In milliseconds. The default duration is 0.5sec.
maxDist
Allow finger movement while pressing. This property expresses the maximum distance it is allowed for the finger to travel before it cancels. The default distance is 10 points.
Event data
See set of event attributes from base handler class. Below is a list of gesture event attributes specific to LongPressGestureHandler
:
x
X coordinate of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the view attached to the handler. Expressed in point units.
y
Y coordinate of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the view attached to the handler. Expressed in point units.
absoluteX
X coordinate of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the root view. The value is expressed in point units. It is recommended to use it instead of x
in cases when the original view can be transformed as an effect of the gesture.
absoluteY
Y coordinate of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the root view. The value is expressed in point units. It is recommended to use it instead of y
in cases when the original view can be transformed as an effect of the gesture.
Example
See the multitap example from GestureHandler Example App or view it directly on your phone by visiting our expo demo.