Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 2.16 KB

File metadata and controls

47 lines (34 loc) · 2.16 KB
id handler-longpress
title LongPressGestureHandler
sidebar_label 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

Gesture events provided to LongPressGestureHandler callbacks does not include any handler specific attributes beside the common set of event attributes from base handler class.

Example

See the multitap example from GestureHandler Example App or view it directly on your phone by visiting our expo demo.

const LongPressButton = () => (
  <LongPressGestureHandler
      onHandlerStateChange={({ nativeEvent }) => {
        if (nativeEvent.state === State.ACTIVE) {
          Alert.alert("I'm being pressed for so long");
        }
      }}
      minDurationMs={800}>
      <View style={styles.box} />
  </LongPressGestureHandler>
);