1e41f4b71Sopenharmony_ci# RotationGesture 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci用于触发旋转手势事件,触发旋转手势的最少手指为2指,最大为5指,最小改变度数为1度。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **说明:** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## 接口 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciRotationGesture(value?: { fingers?: number, angle?: number }) 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**参数:** 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| 参数名称 | 参数类型 | 必填 | 参数描述 | 19e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 20e41f4b71Sopenharmony_ci| fingers | number | 否 | 触发旋转的最少手指数, 最小为2指,最大为5指。<br/>默认值:2 <br/>触发手势手指可以多于fingers数目,但只有先落下的两指参与手势计算。| 21e41f4b71Sopenharmony_ci| angle | number | 否 | 触发旋转手势的最小改变度数,单位为deg。<br/>默认值:1 <br/>**说明:** <br/>当改变度数的值小于等于0或大于360时,会被转化为默认值。| 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci## 事件 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci| 名称 | 功能描述 | 27e41f4b71Sopenharmony_ci| -------- | -------- | 28e41f4b71Sopenharmony_ci| onActionStart(event:(event: [GestureEvent](ts-gesture-settings.md#gestureevent对象说明)) => void) | Rotation手势识别成功回调。 <br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。| 29e41f4b71Sopenharmony_ci| onActionUpdate(event:(event: [GestureEvent](ts-gesture-settings.md#gestureevent对象说明)) => void) | Rotation手势移动过程中回调。 <br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。| 30e41f4b71Sopenharmony_ci| onActionEnd(event:(event: [GestureEvent](ts-gesture-settings.md#gestureevent对象说明)) => void) | Rotation手势识别成功,手指抬起后触发回调。 <br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。| 31e41f4b71Sopenharmony_ci| onActionCancel(event: () => void) | Rotation手势识别成功,接收到触摸取消事件触发回调。<br/>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。| 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci## 属性 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci| 名称 | 类型 |描述 | 38e41f4b71Sopenharmony_ci| ---- | ------ | ---------------------------------------- | 39e41f4b71Sopenharmony_ci| tag<sup>11+</sup> | string | 设置Rotation手势标志,用于自定义手势判定时区分绑定的手势。| 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci## 示例 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci```ts 44e41f4b71Sopenharmony_ci// xxx.ets 45e41f4b71Sopenharmony_ci@Entry 46e41f4b71Sopenharmony_ci@Component 47e41f4b71Sopenharmony_cistruct RotationGestureExample { 48e41f4b71Sopenharmony_ci @State angle: number = 0 49e41f4b71Sopenharmony_ci @State rotateValue: number = 0 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci build() { 52e41f4b71Sopenharmony_ci Column() { 53e41f4b71Sopenharmony_ci Column() { 54e41f4b71Sopenharmony_ci Text('RotationGesture angle:' + this.angle) 55e41f4b71Sopenharmony_ci } 56e41f4b71Sopenharmony_ci .height(200) 57e41f4b71Sopenharmony_ci .width(300) 58e41f4b71Sopenharmony_ci .padding(20) 59e41f4b71Sopenharmony_ci .border({ width: 3 }) 60e41f4b71Sopenharmony_ci .margin(80) 61e41f4b71Sopenharmony_ci .rotate({ angle: this.angle }) 62e41f4b71Sopenharmony_ci // 双指旋转触发该手势事件 63e41f4b71Sopenharmony_ci .gesture( 64e41f4b71Sopenharmony_ci RotationGesture() 65e41f4b71Sopenharmony_ci .onActionStart((event: GestureEvent) => { 66e41f4b71Sopenharmony_ci console.info('Rotation start') 67e41f4b71Sopenharmony_ci }) 68e41f4b71Sopenharmony_ci .onActionUpdate((event: GestureEvent) => { 69e41f4b71Sopenharmony_ci if (event) { 70e41f4b71Sopenharmony_ci this.angle = this.rotateValue + event.angle 71e41f4b71Sopenharmony_ci } 72e41f4b71Sopenharmony_ci }) 73e41f4b71Sopenharmony_ci .onActionEnd((event: GestureEvent) => { 74e41f4b71Sopenharmony_ci this.rotateValue = this.angle 75e41f4b71Sopenharmony_ci console.info('Rotation end') 76e41f4b71Sopenharmony_ci }) 77e41f4b71Sopenharmony_ci ) 78e41f4b71Sopenharmony_ci }.width('100%') 79e41f4b71Sopenharmony_ci } 80e41f4b71Sopenharmony_ci} 81e41f4b71Sopenharmony_ci``` 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci 