1e41f4b71Sopenharmony_ci# Single Gesture 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Tap Gesture 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci```ts 8e41f4b71Sopenharmony_ciTapGesture(value?:{count?:number, fingers?:number}) 9e41f4b71Sopenharmony_ci``` 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciTriggers a tap gesture with one or more taps. This API has two optional parameters: 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci- **count**: number of consecutive taps required for gesture recognition. The default value is **1**. A value less than 1 evaluates to the default value **1**. If there are multiple taps, the timeout interval between a lift and the next tap is 300 ms. 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci- **fingers**: number of fingers required for gesture recognition. The value ranges from 1 to 10. The default value is **1**. If the number of fingers used is less than the specified one within 300 ms after the first finger is tapped, the gesture fails to be recognized. 18e41f4b71Sopenharmony_ci The following example binds a double-tap gesture (a tap gesture whose **count** value is **2**) to the **Text** component: 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci ```ts 21e41f4b71Sopenharmony_ci // xxx.ets 22e41f4b71Sopenharmony_ci @Entry 23e41f4b71Sopenharmony_ci @Component 24e41f4b71Sopenharmony_ci struct Index { 25e41f4b71Sopenharmony_ci @State value: string = ""; 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci build() { 28e41f4b71Sopenharmony_ci Column() { 29e41f4b71Sopenharmony_ci Text('Click twice').fontSize(28) 30e41f4b71Sopenharmony_ci .gesture( 31e41f4b71Sopenharmony_ci // Bind a tap gesture whose count value is 2. 32e41f4b71Sopenharmony_ci TapGesture({ count: 2 }) 33e41f4b71Sopenharmony_ci .onAction((event: GestureEvent|undefined) => { 34e41f4b71Sopenharmony_ci if(event){ 35e41f4b71Sopenharmony_ci this.value = JSON.stringify(event.fingerList[0]); 36e41f4b71Sopenharmony_ci } 37e41f4b71Sopenharmony_ci })) 38e41f4b71Sopenharmony_ci Text(this.value) 39e41f4b71Sopenharmony_ci } 40e41f4b71Sopenharmony_ci .height(200) 41e41f4b71Sopenharmony_ci .width(250) 42e41f4b71Sopenharmony_ci .padding(20) 43e41f4b71Sopenharmony_ci .border({ width: 3 }) 44e41f4b71Sopenharmony_ci .margin(30) 45e41f4b71Sopenharmony_ci } 46e41f4b71Sopenharmony_ci } 47e41f4b71Sopenharmony_ci ``` 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci  50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci## Long Press Gesture 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci```ts 56e41f4b71Sopenharmony_ciLongPressGesture(value?:{fingers?:number, repeat?:boolean, duration?:number}) 57e41f4b71Sopenharmony_ci``` 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ciTriggers a long press gesture. This API has three optional parameters: 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci- **fingers**: minimum number of fingers required for gesture recognition. The value ranges from 1 to 10. The default value is **1**. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci- **repeat**: whether to continuously trigger the event callback. The default value is **false**. 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci- **duration**: minimum hold-down time, in ms. The default value is **500**. 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ciThe following exemplifies how to bind a long press gesture that can be repeatedly triggered to the **Text** component: 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci```ts 75e41f4b71Sopenharmony_ci// xxx.ets 76e41f4b71Sopenharmony_ci@Entry 77e41f4b71Sopenharmony_ci@Component 78e41f4b71Sopenharmony_cistruct Index { 79e41f4b71Sopenharmony_ci @State count: number = 0; 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci build() { 82e41f4b71Sopenharmony_ci Column() { 83e41f4b71Sopenharmony_ci Text('LongPress OnAction:' + this.count).fontSize(28) 84e41f4b71Sopenharmony_ci .gesture( 85e41f4b71Sopenharmony_ci // Bind a long press gesture that can be triggered repeatedly. 86e41f4b71Sopenharmony_ci LongPressGesture({ repeat: true }) 87e41f4b71Sopenharmony_ci .onAction((event: GestureEvent|undefined) => { 88e41f4b71Sopenharmony_ci if(event){ 89e41f4b71Sopenharmony_ci if (event.repeat) { 90e41f4b71Sopenharmony_ci this.count++; 91e41f4b71Sopenharmony_ci } 92e41f4b71Sopenharmony_ci } 93e41f4b71Sopenharmony_ci }) 94e41f4b71Sopenharmony_ci .onActionEnd(() => { 95e41f4b71Sopenharmony_ci this.count = 0; 96e41f4b71Sopenharmony_ci }) 97e41f4b71Sopenharmony_ci ) 98e41f4b71Sopenharmony_ci } 99e41f4b71Sopenharmony_ci .height(200) 100e41f4b71Sopenharmony_ci .width(250) 101e41f4b71Sopenharmony_ci .padding(20) 102e41f4b71Sopenharmony_ci .border({ width: 3 }) 103e41f4b71Sopenharmony_ci .margin(30) 104e41f4b71Sopenharmony_ci } 105e41f4b71Sopenharmony_ci} 106e41f4b71Sopenharmony_ci``` 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci## Pan Gesture 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci```ts 116e41f4b71Sopenharmony_ciPanGesture(value?:{ fingers?:number, direction?:PanDirection, distance?:number}) 117e41f4b71Sopenharmony_ci``` 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ciTriggers a pan gesture, which requires the minimum movement distance (5 vp by default) of a finger on the screen. This API has three optional parameters: 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci- **fingers**: minimum number of fingers required for gesture recognition. The value ranges from 1 to 10. The default value is **1**. 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci- **direction**: pan direction. The enumerated value supports the AND (&) and OR (\|) operations. The default value is **Pandirection.All.** 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci- **distance**: minimum amount of finger movement required for gesture recognition, in vp. The default value is **5**. 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ciThe following exemplifies how to bind a pan gesture to the **Text** component. You can pan a component by modifying the layout and position information of the component in the **PanGesture** callback. 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci```ts 135e41f4b71Sopenharmony_ci// xxx.ets 136e41f4b71Sopenharmony_ci@Entry 137e41f4b71Sopenharmony_ci@Component 138e41f4b71Sopenharmony_cistruct Index { 139e41f4b71Sopenharmony_ci @State offsetX: number = 0; 140e41f4b71Sopenharmony_ci @State offsetY: number = 0; 141e41f4b71Sopenharmony_ci @State positionX: number = 0; 142e41f4b71Sopenharmony_ci @State positionY: number = 0; 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci build() { 145e41f4b71Sopenharmony_ci Column() { 146e41f4b71Sopenharmony_ci Text('PanGesture Offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY) 147e41f4b71Sopenharmony_ci .fontSize(28) 148e41f4b71Sopenharmony_ci .height(200) 149e41f4b71Sopenharmony_ci .width(300) 150e41f4b71Sopenharmony_ci .padding(20) 151e41f4b71Sopenharmony_ci .border({ width: 3 }) 152e41f4b71Sopenharmony_ci // Bind the layout and position information to the component. 153e41f4b71Sopenharmony_ci .translate({ x: this.offsetX, y: this.offsetY, z: 0 }) 154e41f4b71Sopenharmony_ci .gesture( 155e41f4b71Sopenharmony_ci // Bind a pan gesture to the component. 156e41f4b71Sopenharmony_ci PanGesture() 157e41f4b71Sopenharmony_ci .onActionStart((event: GestureEvent|undefined) => { 158e41f4b71Sopenharmony_ci console.info('Pan start'); 159e41f4b71Sopenharmony_ci }) 160e41f4b71Sopenharmony_ci // When the pan gesture is recognized, modify the layout and position information of the component based on the callback. 161e41f4b71Sopenharmony_ci .onActionUpdate((event: GestureEvent|undefined) => { 162e41f4b71Sopenharmony_ci if(event){ 163e41f4b71Sopenharmony_ci this.offsetX = this.positionX + event.offsetX; 164e41f4b71Sopenharmony_ci this.offsetY = this.positionY + event.offsetY; 165e41f4b71Sopenharmony_ci } 166e41f4b71Sopenharmony_ci }) 167e41f4b71Sopenharmony_ci .onActionEnd(() => { 168e41f4b71Sopenharmony_ci this.positionX = this.offsetX; 169e41f4b71Sopenharmony_ci this.positionY = this.offsetY; 170e41f4b71Sopenharmony_ci }) 171e41f4b71Sopenharmony_ci ) 172e41f4b71Sopenharmony_ci } 173e41f4b71Sopenharmony_ci .height(200) 174e41f4b71Sopenharmony_ci .width(250) 175e41f4b71Sopenharmony_ci } 176e41f4b71Sopenharmony_ci} 177e41f4b71Sopenharmony_ci``` 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ci>**NOTE** 184e41f4b71Sopenharmony_ci> 185e41f4b71Sopenharmony_ci>Most swipeable components, such as **List**, **Grid**, **Scroll**, and **Tab**, allow for swiping through the pan gesture. If you bind the pan gesture or [swipe gesture](#swipe-gesture) to a child of these components, competition for gesture recognition will result. 186e41f4b71Sopenharmony_ci> 187e41f4b71Sopenharmony_ci>If the pan gesture is bound to a child component, the component, instead of its parent, responds to the pan gestures recognized. If you want the parent component to respond, you need to modify the gesture binding method or transfer messages from the child component to the parent component, or modify the **distance** parameters in **PanGesture** for the components. If the swipe gesture is bound to a child component, to allow the parent component to respond to gestures, you need to modify the parameters of **PanGesture** and **SwipeGesture**, since the swipe gesture and pan gesture are recognized with different conditions. 188e41f4b71Sopenharmony_ci> 189e41f4b71Sopenharmony_ci>An inappropriate value can lead to slow response or lagging. 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci## Pinch Gesture 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci```ts 196e41f4b71Sopenharmony_ciPinchGesture(value?:{fingers?:number, distance?:number}) 197e41f4b71Sopenharmony_ci``` 198e41f4b71Sopenharmony_ci 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ciTriggers a pinch gesture. This API has two optional parameters: 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci 203e41f4b71Sopenharmony_ci- **fingers**: minimum number of fingers required for gesture recognition. The value ranges from 2 to 5. The default value is **2**. 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci- **distance**: minimum distance between fingers required for gesture recognition, in vp. The default value is **5**. 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ciThe following exemplifies how to bind a three-finger pinch gesture to the **Column** component. You can obtain the scale factor from the callback of **PinchGesture** to scale the component. 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci```ts 213e41f4b71Sopenharmony_ci// xxx.ets 214e41f4b71Sopenharmony_ci@Entry 215e41f4b71Sopenharmony_ci@Component 216e41f4b71Sopenharmony_cistruct Index { 217e41f4b71Sopenharmony_ci @State scaleValue: number = 1; 218e41f4b71Sopenharmony_ci @State pinchValue: number = 1; 219e41f4b71Sopenharmony_ci @State pinchX: number = 0; 220e41f4b71Sopenharmony_ci @State pinchY: number = 0; 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ci build() { 223e41f4b71Sopenharmony_ci Column() { 224e41f4b71Sopenharmony_ci Column() { 225e41f4b71Sopenharmony_ci Text('PinchGesture scale:\n' + this.scaleValue) 226e41f4b71Sopenharmony_ci Text('PinchGesture center:\n(' + this.pinchX + ',' + this.pinchY + ')') 227e41f4b71Sopenharmony_ci } 228e41f4b71Sopenharmony_ci .height(200) 229e41f4b71Sopenharmony_ci .width(300) 230e41f4b71Sopenharmony_ci .border({ width: 3 }) 231e41f4b71Sopenharmony_ci .margin({ top: 100 }) 232e41f4b71Sopenharmony_ci // Bind the scale factor to the component so that it is scaled by changing the scale factor. 233e41f4b71Sopenharmony_ci .scale({ x: this.scaleValue, y: this.scaleValue, z: 1 }) 234e41f4b71Sopenharmony_ci .gesture( 235e41f4b71Sopenharmony_ci // Bind a three-finger pinch gesture to the component. 236e41f4b71Sopenharmony_ci PinchGesture({ fingers: 3 }) 237e41f4b71Sopenharmony_ci .onActionStart((event: GestureEvent|undefined) => { 238e41f4b71Sopenharmony_ci console.info('Pinch start'); 239e41f4b71Sopenharmony_ci }) 240e41f4b71Sopenharmony_ci // When the pinch gesture is triggered, the callback can be used to obtain the scale factor. 241e41f4b71Sopenharmony_ci .onActionUpdate((event: GestureEvent|undefined) => { 242e41f4b71Sopenharmony_ci if(event){ 243e41f4b71Sopenharmony_ci this.scaleValue = this.pinchValue * event.scale; 244e41f4b71Sopenharmony_ci this.pinchX = event.pinchCenterX; 245e41f4b71Sopenharmony_ci this.pinchY = event.pinchCenterY; 246e41f4b71Sopenharmony_ci } 247e41f4b71Sopenharmony_ci }) 248e41f4b71Sopenharmony_ci .onActionEnd(() => { 249e41f4b71Sopenharmony_ci this.pinchValue = this.scaleValue; 250e41f4b71Sopenharmony_ci console.info('Pinch end'); 251e41f4b71Sopenharmony_ci }) 252e41f4b71Sopenharmony_ci ) 253e41f4b71Sopenharmony_ci } 254e41f4b71Sopenharmony_ci } 255e41f4b71Sopenharmony_ci} 256e41f4b71Sopenharmony_ci``` 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci## Rotation Gesture 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci```ts 266e41f4b71Sopenharmony_ciRotationGesture(value?:{fingers?:number, angle?:number}) 267e41f4b71Sopenharmony_ci``` 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci 270e41f4b71Sopenharmony_ciTriggers a rotation gesture. This API has two optional parameters: 271e41f4b71Sopenharmony_ci 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci- **fingers**: minimum number of fingers required for gesture recognition. The value ranges from 2 to 5. The default value is **2**. 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci- **angle**: minimum angle of rotation required for gesture recognition, in deg. The default value is **1**. 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci 278e41f4b71Sopenharmony_ciThe following exemplifies how to bind a rotation gesture to the **Text** component. You can obtain the rotation angle from the callback of **RotationGesture** and implement rotation on the component. 279e41f4b71Sopenharmony_ci 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci 282e41f4b71Sopenharmony_ci```ts 283e41f4b71Sopenharmony_ci// xxx.ets 284e41f4b71Sopenharmony_ci@Entry 285e41f4b71Sopenharmony_ci@Component 286e41f4b71Sopenharmony_cistruct Index { 287e41f4b71Sopenharmony_ci @State angle: number = 0; 288e41f4b71Sopenharmony_ci @State rotateValue: number = 0; 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci build() { 291e41f4b71Sopenharmony_ci Column() { 292e41f4b71Sopenharmony_ci Text('RotationGesture angle:' + this.angle).fontSize(28) 293e41f4b71Sopenharmony_ci // Bind the rotation to the component so that it is rotated by changing the rotation angle. 294e41f4b71Sopenharmony_ci .rotate({ angle: this.angle }) 295e41f4b71Sopenharmony_ci .gesture( 296e41f4b71Sopenharmony_ci RotationGesture() 297e41f4b71Sopenharmony_ci .onActionStart((event: GestureEvent|undefined) => { 298e41f4b71Sopenharmony_ci console.info('RotationGesture is onActionStart'); 299e41f4b71Sopenharmony_ci }) 300e41f4b71Sopenharmony_ci // When the rotation gesture takes effect, the rotation angle is obtained through the callback and the component is rotated accordingly. 301e41f4b71Sopenharmony_ci .onActionUpdate((event: GestureEvent|undefined) => { 302e41f4b71Sopenharmony_ci if(event){ 303e41f4b71Sopenharmony_ci this.angle = this.rotateValue + event.angle; 304e41f4b71Sopenharmony_ci } 305e41f4b71Sopenharmony_ci console.info('RotationGesture is onActionEnd'); 306e41f4b71Sopenharmony_ci }) 307e41f4b71Sopenharmony_ci // When the fingers lift from the screen, the component is fixed at the angle where rotation ends. 308e41f4b71Sopenharmony_ci .onActionEnd(() => { 309e41f4b71Sopenharmony_ci this.rotateValue = this.angle; 310e41f4b71Sopenharmony_ci console.info('RotationGesture is onActionEnd'); 311e41f4b71Sopenharmony_ci }) 312e41f4b71Sopenharmony_ci .onActionCancel(() => { 313e41f4b71Sopenharmony_ci console.info('RotationGesture is onActionCancel'); 314e41f4b71Sopenharmony_ci }) 315e41f4b71Sopenharmony_ci ) 316e41f4b71Sopenharmony_ci .height(200) 317e41f4b71Sopenharmony_ci .width(300) 318e41f4b71Sopenharmony_ci .padding(20) 319e41f4b71Sopenharmony_ci .border({ width: 3 }) 320e41f4b71Sopenharmony_ci .margin(100) 321e41f4b71Sopenharmony_ci } 322e41f4b71Sopenharmony_ci } 323e41f4b71Sopenharmony_ci} 324e41f4b71Sopenharmony_ci``` 325e41f4b71Sopenharmony_ci 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci## Swipe Gesture 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_ci```ts 334e41f4b71Sopenharmony_ciSwipeGesture(value?:{fingers?:number, direction?:SwipeDirection, speed?:number}) 335e41f4b71Sopenharmony_ci``` 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ciTriggers a swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher. This API has three optional parameters: 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci 341e41f4b71Sopenharmony_ci- **fingers**: minimum number of fingers required for gesture recognition. The value ranges from 1 to 10. The default value is **1**. 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci- **direction**: swipe direction. The enumerated value supports the AND (&) and OR (\|) operations. The default value is **SwipeDirection.All**. 344e41f4b71Sopenharmony_ci 345e41f4b71Sopenharmony_ci- **speed**: minimum speed of the swipe gesture, in vp/s. The default value is **100**. 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ciThe following exemplifies how to bind a swipe gesture to the **Column** component to rotate the component: 349e41f4b71Sopenharmony_ci 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci```ts 353e41f4b71Sopenharmony_ci// xxx.ets 354e41f4b71Sopenharmony_ci@Entry 355e41f4b71Sopenharmony_ci@Component 356e41f4b71Sopenharmony_cistruct Index { 357e41f4b71Sopenharmony_ci @State rotateAngle: number = 0; 358e41f4b71Sopenharmony_ci @State speed: number = 1; 359e41f4b71Sopenharmony_ci 360e41f4b71Sopenharmony_ci build() { 361e41f4b71Sopenharmony_ci Column() { 362e41f4b71Sopenharmony_ci Column() { 363e41f4b71Sopenharmony_ci Text("SwipeGesture speed\n" + this.speed) 364e41f4b71Sopenharmony_ci Text("SwipeGesture angle\n" + this.rotateAngle) 365e41f4b71Sopenharmony_ci } 366e41f4b71Sopenharmony_ci .border({ width: 3 }) 367e41f4b71Sopenharmony_ci .width(300) 368e41f4b71Sopenharmony_ci .height(200) 369e41f4b71Sopenharmony_ci .margin(100) 370e41f4b71Sopenharmony_ci // Bind rotation to the <Column> component and change the rotation angle through the swipe speed and angle. 371e41f4b71Sopenharmony_ci .rotate({ angle: this.rotateAngle }) 372e41f4b71Sopenharmony_ci .gesture( 373e41f4b71Sopenharmony_ci // Bind to the component the swipe gesture that can be triggered only when the user swipes in the vertical direction. 374e41f4b71Sopenharmony_ci SwipeGesture({ direction: SwipeDirection.Vertical }) 375e41f4b71Sopenharmony_ci // When the swipe gesture is triggered, the swipe speed and angle are obtained, which can be used to modify the layout parameters. 376e41f4b71Sopenharmony_ci .onAction((event: GestureEvent|undefined) => { 377e41f4b71Sopenharmony_ci if(event){ 378e41f4b71Sopenharmony_ci this.speed = event.speed; 379e41f4b71Sopenharmony_ci this.rotateAngle = event.angle; 380e41f4b71Sopenharmony_ci } 381e41f4b71Sopenharmony_ci }) 382e41f4b71Sopenharmony_ci ) 383e41f4b71Sopenharmony_ci } 384e41f4b71Sopenharmony_ci } 385e41f4b71Sopenharmony_ci} 386e41f4b71Sopenharmony_ci``` 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci>**NOTE** 393e41f4b71Sopenharmony_ci> 394e41f4b71Sopenharmony_ci>When the swipe gesture and pan gesture are simultaneously bound to a component in default or mutually exclusive mode, competition for gesture recognition occurs. Whichever gesture meets the trigger condition first is recognized. By default, a swipe gesture is recognized when the swipe speed reaches 100 vp/s, and a pan gesture is recognized when the amount of finger movement reaches 5 vp. To allow a specific gesture to be recognized before the other, you can modify the parameter settings in **SwipeGesture** and **PanGesture**. 395