此组件为常见的触摸手势(轻触、双击、长按、平移和捏合)提供支持。它还处理常见的基于鼠标的手势,包括双击和滚轮输入。
有关待定手势的信息通过事件处理程序返回。调用者可以通过指定这些事件处理程序来指定他们感兴趣的手势。例如,如果您对双击和水平平移感兴趣,请提供 onDoubleTap 和 onPanHorizontal 处理程序。
// Alternate text for screen readers.
accessibilityLabel: string = undefined;
// Traits used to hint screen readers, etc.
accessibilityTraits: AccessibilityTrait | AccessibilityTrait[] = undefined;
// Expose the element and/or its children as accessible to Screen readers
importantForAccessibility?: ImportantForAccessibility =
ImportantForAccessibility.Yes;
// Gestures and attributes that apply only to touch inputs
onPinchZoom: (gestureState: MultiTouchGestureState) => void = undefined;
onRotate: (gestureState: MultiTouchGestureState) => void = undefined;
// Gestures and attributes that apply only to mouse inputs
onScrollWheel: (gestureState: ScrollWheelGestureState) => void = undefined;
mouseOverCursor: GestureMouseCursor = undefined;
// Gestures and attributes that apply to either touch or mouse inputs
onPan: (gestureState: PanGestureState) => void = undefined;
onPanVertical: (gestureState: PanGestureState) => void = undefined;
onPanHorizontal: (gestureState: PanGestureState) => void = undefined;
onTap: (gestureState: TapGestureState) => void = undefined;
onDoubleTap: (gestureState: TapGestureState) => void = undefined;
onContextMenu: (gestureState: TapGestureState) => void = undefined;
onLongPress: (gestureState: TapGestureState) => void = undefined;
// Focus Events
onFocus: (e: FocusEvent) => void = undefined;
onBlur: (e: FocusEvent) => void = undefined;
// Keyboard Events
onKeyPress: (e: KeyboardEvent) => void = undefined;
// We can set vertical or horizontal as preferred
preferredPan: PreferredPanGesture = undefined; // Horizontal or vertical
// How many pixels (in either horizontal or vertical direction) until
// pan is recognized? Default is 10. Can be any value > 0.
panPixelThreshold: number = undefined;
// Something else wants to become responder. Should this view
// release the responder? Setting true allows release.
releaseOnRequest: boolean = false;
// ID that can be used to identify the instantiated element for testing purposes.
testId: string = undefined;
// Sets the accessibility focus to the component.
focus(): void;