提交 6b1ccca4 编写于 作者: E ester.zhou

udpate ts-basic-gestures-longpressgesture.md (8370)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 539ce4db
# LongPressGesture # LongPressGesture
**LongPressGesture** is used to trigger a long press gesture, which requires one or more fingers with a minimum 500 ms hold-down time.
> **NOTE**
>
> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
> **NOTE**<br>
> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -14,31 +17,31 @@ None ...@@ -14,31 +17,31 @@ None
LongPressGesture(options?: { fingers?: number, repeat?: boolean, duration?: number }) LongPressGesture(options?: { fingers?: number, repeat?: boolean, duration?: number })
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| fingers | number | No | 1 | Minimum number of fingers to trigger a long press gesture. The value ranges from 1 to 10. | | fingers | number | No| 1 | Minimum number of fingers to trigger a long press gesture. The value ranges from 1 to 10.|
| repeat | boolean | No | false | Whether to continuously trigger the event callback. | | repeat | boolean | No| false | Whether to continuously trigger the event callback.|
| duration | number | No | 500 | Minimum hold-down time, in ms. | | duration | number | No| 500 | Minimum hold-down time, in ms.|
## Events ## Events
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| onAction((event?: GestureEvent) =&gt; void) | Callback invoked when a long press gesture is recognized. | | onAction((event?: GestureEvent) =&gt; void) | Callback invoked when a long press gesture is recognized.|
| onActionEnd((event?: GestureEvent) =&gt; void) | Callback invoked when the finger used for a long press gesture is lift. | | onActionEnd((event?: GestureEvent) =&gt; void) | Callback invoked when the finger used for a long press gesture is lift.|
| onActionCancel(event: () =&gt; void) | Callback invoked when a tap cancellation event is received after a long press gesture is recognized. | | onActionCancel(event: () =&gt; void) | Callback invoked when a tap cancellation event is received after a long press gesture is recognized.|
- GestureEvent attributes related to the long press gesture - GestureEvent attributes related to the long press gesture
| Name | Type | Description | | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| repeat | boolean | Whether the event is repeated. | | repeat | boolean | Whether the event is repeated.|
## Example ## Example
```ts
``` // xxx.ets
@Entry @Entry
@Component @Component
struct LongPressGestureExample { struct LongPressGestureExample {
......
# PanGesture # PanGesture
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** **PanGesture** is used to trigger a pan gesture, which requires a minimum 5 vp movement distance of a finger on the screen.
> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
> **NOTE**
>
> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -10,65 +14,66 @@ None ...@@ -10,65 +14,66 @@ None
## APIs ## APIs
PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: number } | [PanGestureOption](#pangestureoptions)) PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: number } | [PanGestureOptions](#pangestureoptions))
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| fingers | number | No | 1 | Minimum number of fingers to trigger a slide gesture. The value ranges from 1 to 10. | | fingers | number | No| 1 | Minimum number of fingers to trigger a pan gesture. The value ranges from 1 to 10.|
| direction | PanDirection | No | All | Slide direction. The enumerated value supports the AND (&amp;) and OR (\|) operations. | | direction | PanDirection | No| All | Pan direction. The enumerated value supports the AND (&amp;) and OR (\|)|operations.|
| distance | number | No | 5.0 | Minimum slide recognition distance, in vp. | | distance | number | No| 5.0 | Minimum pan distance to trigger the gesture, in vp.<br>**NOTE**<br>If a pan gesture and tab swipe occur at the same time, set **distance** to **1** so that the gesture can be more easily recognized.|
- PanDirection enums - PanDirection enums
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| All | All directions. | | All | All directions.|
| Horizontal | Horizontal slide. | | Horizontal | Horizontal panning.|
| Vertical | Vertical slide. | | Vertical | Vertical panning.|
| Left | Slide to the left. | | Left | Panning to the left.|
| Right | Slide to the right. | | Right | Panning to the right.|
| Up | Slide up. | | Up | Panning up.|
| Down | Slide down. | | Down | Panning down.|
| None | Slide disabled. | | None | Panning disabled.|
### PanGestureOptions ### PanGestureOptions
The attributes of the slide gesture recognizer can be dynamically modified using the **PanGestureOptions** AP. This avoids modifying attributes through status variables, which will cause the UI to be refreshed. The attributes of the pan gesture recognizer can be dynamically modified using the **PanGestureOptions** API. This avoids modifying attributes through state variables, which will cause the UI to be refreshed.
PanGestureOptions(options?: { fingers?: number, direction?: PanDirection, distance?: number }) PanGestureOptions(options?: { fingers?: number, direction?: PanDirection, distance?: number })
- Parameters - Parameters
For details, see **PanGesture**.
For details, see **PanGesture**.
- APIs - APIs
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| setDirection(value: PanDirection) | Sets the direction. | | setDirection(value: PanDirection) | Sets the direction.|
| setDistance(value: number) | Sets the distance. | | setDistance(value: number) | Sets the distance.|
| setFingers(value: number) | Sets the number of fingers. | | setFingers(value: number) | Sets the number of fingers.|
## Events ## Events
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| onActionStart(callback: (event?: GestureEvent) =&gt; void) | Callback for the pan gestures reorganization event. | | onActionStart(callback: (event?: GestureEvent) =&gt; void) | Callback invoked when a pan gesture is recognized.|
| onActionUpdate(callback: (event?: GestureEvent) =&gt; void) | Callback invoked when a pan gesture is recognized. | | onActionUpdate(callback: (event?: GestureEvent) =&gt; void) | Callback invoked when the pan gesture status is updated.|
| onActionEnd(callback: (event?: GestureEvent) =&gt; void) | Callback invoked when the finger used for a pan gesture is lift. | | onActionEnd(callback: (event?: GestureEvent) =&gt; void) | Callback invoked when the finger used for a pan gesture is lift.|
| onActionCancel(callback: () =&gt; void) | Callback invoked when a tap cancellation event is received after a pan gesture is recognized. | | onActionCancel(callback: () =&gt; void) | Callback invoked when a tap cancellation event is received after a pan gesture is recognized.|
- GestureEvent attributes related to the pan gesture - GestureEvent attributes related to the pan gesture
| Name | Type | Description | | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| offsetX | number | Offset of the gesture event, in vp. | | offsetX | number | Offset of the gesture event, in vp.|
| offsetY | number | Offset of the gesture event, in vp. | | offsetY | number | Offset of the gesture event, in vp.|
## Example ## Example
```ts
``` // xxx.ets
@Entry @Entry
@Component @Component
struct PanGestureExample { struct PanGestureExample {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册