1e41f4b71Sopenharmony_ci# PinchGesture
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci**PinchGesture** is used to trigger a pinch gesture, which requires two to five fingers with a minimum 5 vp distance between the fingers.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>  This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## APIs
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciPinchGesture(value?: { fingers?: number, distance?: 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 pinch. The value ranges from 2 to 5.<br>Default value: **2**<br>While more fingers than the minimum number can be pressed to trigger the gesture, only the first fingers of the minimum number participate in gesture calculation.|
21e41f4b71Sopenharmony_ci| distance | number | No| Minimum recognition distance, in vp.<br>Default value: **5**<br>**NOTE**<br> If the value is less than or equal to 0, it will be converted to the default value.|
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci## Events
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci| Name| Description|
27e41f4b71Sopenharmony_ci| -------- | -------- |
28e41f4b71Sopenharmony_ci| onActionStart(event:(event: [GestureEvent](ts-gesture-settings.md#gestureevent)) =&gt; void) | Triggered when a pinch gesture is recognized.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
29e41f4b71Sopenharmony_ci| onActionUpdate(event:(event: [GestureEvent](ts-gesture-settings.md#gestureevent)) =&gt; void) | Triggered when the user moves the finger in the pinch gesture on the screen.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
30e41f4b71Sopenharmony_ci| onActionEnd(event:(event: [GestureEvent](ts-gesture-settings.md#gestureevent)) =&gt; void) | Triggered when the finger used for the pinch gesture is lift.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
31e41f4b71Sopenharmony_ci| onActionCancel(event: () =&gt; void) | Triggered when a tap cancellation event is received after the pinch gesture is recognized.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci## Attributes
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci| Name| Type   |Description                                       |
38e41f4b71Sopenharmony_ci| ----  | ------  | ---------------------------------------- |
39e41f4b71Sopenharmony_ci| tag<sup>11+</sup>   | string  | Tag for the pinch gesture. It is used to distinguish the gesture during custom gesture judgment.|
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci## Example
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci```ts
44e41f4b71Sopenharmony_ci// xxx.ets
45e41f4b71Sopenharmony_ci@Entry
46e41f4b71Sopenharmony_ci@Component
47e41f4b71Sopenharmony_cistruct PinchGestureExample {
48e41f4b71Sopenharmony_ci  @State scaleValue: number = 1
49e41f4b71Sopenharmony_ci  @State pinchValue: number = 1
50e41f4b71Sopenharmony_ci  @State pinchX: number = 0
51e41f4b71Sopenharmony_ci  @State pinchY: number = 0
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci  build() {
54e41f4b71Sopenharmony_ci    Column() {
55e41f4b71Sopenharmony_ci      Column() {
56e41f4b71Sopenharmony_ci        Text('PinchGesture scale:\n' + this.scaleValue)
57e41f4b71Sopenharmony_ci        Text('PinchGesture center:\n(' + this.pinchX + ',' + this.pinchY + ')')
58e41f4b71Sopenharmony_ci      }
59e41f4b71Sopenharmony_ci      .height(200)
60e41f4b71Sopenharmony_ci      .width(300)
61e41f4b71Sopenharmony_ci      .padding(20)
62e41f4b71Sopenharmony_ci      .border({ width: 3 })
63e41f4b71Sopenharmony_ci      .margin({ top: 100 })
64e41f4b71Sopenharmony_ci      .scale({ x: this.scaleValue, y: this.scaleValue, z: 1 })
65e41f4b71Sopenharmony_ci      // The gesture event is triggered by pinching three fingers together.
66e41f4b71Sopenharmony_ci      .gesture(
67e41f4b71Sopenharmony_ci      PinchGesture({ fingers: 3 })
68e41f4b71Sopenharmony_ci        .onActionStart((event: GestureEvent) => {
69e41f4b71Sopenharmony_ci          console.info('Pinch start')
70e41f4b71Sopenharmony_ci        })
71e41f4b71Sopenharmony_ci        .onActionUpdate((event: GestureEvent) => {
72e41f4b71Sopenharmony_ci          if (event) {
73e41f4b71Sopenharmony_ci            this.scaleValue = this.pinchValue * event.scale
74e41f4b71Sopenharmony_ci            this.pinchX = event.pinchCenterX
75e41f4b71Sopenharmony_ci            this.pinchY = event.pinchCenterY
76e41f4b71Sopenharmony_ci          }
77e41f4b71Sopenharmony_ci        })
78e41f4b71Sopenharmony_ci        .onActionEnd((event: GestureEvent) => {
79e41f4b71Sopenharmony_ci          this.pinchValue = this.scaleValue
80e41f4b71Sopenharmony_ci          console.info('Pinch end')
81e41f4b71Sopenharmony_ci        })
82e41f4b71Sopenharmony_ci      )
83e41f4b71Sopenharmony_ci    }.width('100%')
84e41f4b71Sopenharmony_ci  }
85e41f4b71Sopenharmony_ci}
86e41f4b71Sopenharmony_ci```
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci ![en-us_image_0000001174582848](figures/en-us_image_0000001174582848.png)
89