# PinchGesture
## 接口
PinchGesture\(options?: \{ fingers?: number, distance?: number \}\)
- 参数
参数名称
|
参数类型
|
必填
|
默认值
|
参数描述
|
fingers
|
number
|
否
|
2
|
触发捏合的最少手指数, 最小为2指,最大为5指。
|
distance
|
number
|
否
|
3.0
|
最小识别距离,单位为vp。
|
## 事件
名称
|
功能描述
|
onActionStart((event?: GestureEvent) => void)
|
Pinch手势识别成功回调。
|
onActionUpdate((event?: GestureEvent) => void)
|
Pinch手势移动过程中回调。
|
onActionEnd((event?: GestureEvent) => void)
|
Pinch手势识别成功,手指抬起后触发回调。
|
onActionCancel(event: () => void)
|
Pinch手势识别成功,接收到触摸取消事件触发回调。
|
## 示例
```
@Entry
@Component
struct PinchGestureExample {
@State scale: number = 1
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('PinchGesture scale:' + this.scale)
}
.height(100).width(200).padding(20).border({ width: 1 }).margin(80)
.scale({ x: this.scale, y: this.scale, z: this.scale })
.gesture(
PinchGesture()
.onActionStart((event: GestureEvent) => {
console.info('Pinch start')
})
.onActionUpdate((event: GestureEvent) => {
this.scale = event.scale
})
.onActionEnd(() => {
console.info('Pinch end')
})
)
}
}
```
