| id | use-long-press-gesture |
|---|---|
| title | Long press gesture |
| sidebar_label | Long press gesture |
| sidebar_position | 3 |
import { vanishOnMobile, appearOnMobile, webContainer } from '@site/src/utils/getGestureStyles';
import useBaseUrl from '@docusaurus/useBaseUrl';
import LongPressGestureBasic from '@site/static/examples/LongPressGestureBasic'; import LongPressGestureBasicSrc from '!!raw-loader!@site/static/examples/LongPressGestureBasic';
import HeaderWithBadge from '@site/src/components/HeaderWithBadge';
import BaseEventData from './_shared/base-gesture-event-data.mdx'; import BaseGestureConfig from './_shared/base-gesture-config.mdx'; import BaseGestureCallbacks from './_shared/base-gesture-callbacks.mdx'; import SharedValueInfo from './_shared/shared-value-info.md';
import CollapsibleCode from '@site/src/components/CollapsibleCode';
import LongPressExample from '!!raw-loader!./_examples/LongPressExample';
Gesture that activates when the corresponding view is pressed for a sufficiently long time. This gesture will deactivate immediately after the finger is released. The gesture will fail to recognize a touch event if the finger is lifted before the minimum required time or if the finger is moved further than the allowable distance.
<CollapsibleCode label="Show full example" expandedLabel="Hide full example" lineBounds={[7, 23]} src={LongPressExample}/>
minDuration: number | SharedValue<number>;Minimum time, expressed in milliseconds, that a finger must remain pressed on the corresponding view. The default value is 500.
maxDistance: number | SharedValue<number>;Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a long press gesture. If the finger travels further than the defined distance and the gesture hasn't yet activated, it will fail to recognize the gesture. The default value is 10.
<HeaderWithBadge platforms={['android', 'web']}>
<CollapsibleCode label="Show composed types definitions" expandedLabel="Hide composed types definitions" lineBounds={[0, 1]} collapsed={false} src={` mouseButton: MouseButton | SharedValue;
enum MouseButton { LEFT, RIGHT, MIDDLE, BUTTON_4, BUTTON_5, ALL, } `}/>
Allows users to choose which mouse button should handler respond to. Arguments can be combined using | operator, e.g. mouseButton(MouseButton.LEFT | MouseButton.RIGHT). Default value is set to MouseButton.LEFT.
<BaseGestureCallbacks gesture={"LongPress"}/>
x: number;X coordinate, expressed in points, 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 GestureDetector.
y: number;Y coordinate, expressed in points, 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 GestureDetector.
absoluteX: number;X coordinate, expressed in points, of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the window. It is recommended to use absoluteX instead of x in cases when the view attached to the GestureDetector can be transformed as an effect of the gesture.
absoluteY: number;Y coordinate, expressed in points, of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the window. It is recommended to use absoluteY instead of y in cases when the view attached to the GestureDetector can be transformed as an effect of the gesture.
duration: number;Duration of the long press (time since the start of the gesture), expressed in milliseconds.