1e41f4b71Sopenharmony_ci# SwipeGesture 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci**SwipeGesture** is used to implement a swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This gesture is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## APIs 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciSwipeGesture(value?: { fingers?: number, direction?: SwipeDirection, speed?: number }) 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**Parameters** 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 19e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 20e41f4b71Sopenharmony_ci| fingers | number | No| Minimum number of fingers to trigger a swipe gesture. The value ranges from 1 to 10.<br>Default value: **1**| 21e41f4b71Sopenharmony_ci| direction | [swipeDirection](#swipedirection)| No| Swipe direction.<br>Default value: **SwipeDirection.All**| 22e41f4b71Sopenharmony_ci| speed | number | No| Minimum speed of the swipe gesture.<br>Default value: 100 vp/s<br>**NOTE**<br>If the value is less than or equal to 0, it will be converted to the default value.| 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci## SwipeDirection 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci| Name| Description| 29e41f4b71Sopenharmony_ci| -------- | -------- | 30e41f4b71Sopenharmony_ci| All | All directions.| 31e41f4b71Sopenharmony_ci| Horizontal | Horizontal direction. The gesture event is triggered when the angle between the finger moving direction and the x-axis is less than 45 degrees.| 32e41f4b71Sopenharmony_ci| Vertical | Vertical direction. The gesture event is triggered when the angle between the finger moving direction and the y-axis is less than 45 degrees.| 33e41f4b71Sopenharmony_ci| None | Swiping disabled.| 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci## Events 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci| Name| Description| 39e41f4b71Sopenharmony_ci| -------- | -------- | 40e41f4b71Sopenharmony_ci| onAction(event:(event: [GestureEvent](ts-gesture-settings.md#gestureevent)) => void) | Invoked when the swipe gesture is recognized.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci## Attributes 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci| Name| Type |Description | 47e41f4b71Sopenharmony_ci| ---- | ------ | ---------------------------------------- | 48e41f4b71Sopenharmony_ci| tag<sup>11+</sup> | string | Tag for the swipe gesture. It is used to distinguish the gesture during custom gesture judgment.| 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci## Example 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci```ts 53e41f4b71Sopenharmony_ci// xxx.ets 54e41f4b71Sopenharmony_ci@Entry 55e41f4b71Sopenharmony_ci@Component 56e41f4b71Sopenharmony_cistruct SwipeGestureExample { 57e41f4b71Sopenharmony_ci @State rotateAngle: number = 0 58e41f4b71Sopenharmony_ci @State speed: number = 1 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci build() { 61e41f4b71Sopenharmony_ci Column() { 62e41f4b71Sopenharmony_ci Column() { 63e41f4b71Sopenharmony_ci Text("SwipeGesture speed\n" + this.speed) 64e41f4b71Sopenharmony_ci Text("SwipeGesture angle\n" + this.rotateAngle) 65e41f4b71Sopenharmony_ci } 66e41f4b71Sopenharmony_ci .border({ width: 3 }) 67e41f4b71Sopenharmony_ci .width(300) 68e41f4b71Sopenharmony_ci .height(200) 69e41f4b71Sopenharmony_ci .margin(100) 70e41f4b71Sopenharmony_ci .rotate({ angle: this.rotateAngle }) 71e41f4b71Sopenharmony_ci // The gesture event is triggered by swiping vertically with one finger. 72e41f4b71Sopenharmony_ci .gesture( 73e41f4b71Sopenharmony_ci SwipeGesture({ direction: SwipeDirection.Vertical }) 74e41f4b71Sopenharmony_ci .onAction((event: GestureEvent) => { 75e41f4b71Sopenharmony_ci if (event) { 76e41f4b71Sopenharmony_ci this.speed = event.speed 77e41f4b71Sopenharmony_ci this.rotateAngle = event.angle 78e41f4b71Sopenharmony_ci } 79e41f4b71Sopenharmony_ci }) 80e41f4b71Sopenharmony_ci ) 81e41f4b71Sopenharmony_ci }.width('100%') 82e41f4b71Sopenharmony_ci } 83e41f4b71Sopenharmony_ci} 84e41f4b71Sopenharmony_ci``` 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci  87