W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
用于觸發(fā)旋轉(zhuǎn)手勢事件,觸發(fā)旋轉(zhuǎn)手勢的最少手指為2指,最大為5指,最小改變度數(shù)為1度。
從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標單獨標記該內(nèi)容的起始版本。
RotationGesture(value?: { fingers?: number, angle?: number })
參數(shù):
參數(shù)名稱 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
---|---|---|---|
fingers | number | 否 | 觸發(fā)旋轉(zhuǎn)的最少手指數(shù), 最小為2指,最大為5指。 默認值:2 |
angle | number | 否 | 觸發(fā)旋轉(zhuǎn)手勢的最小改變度數(shù),單位為deg。 默認值:1 |
名稱 | 功能描述 |
---|---|
onActionStart(event:(event?: GestureEvent) => void) | Rotation手勢識別成功回調(diào)。 |
onActionUpdate(event:(event?: GestureEvent) => void) | Rotation手勢移動過程中回調(diào)。 |
onActionEnd(event:(event?: GestureEvent) => void) | Rotation手勢識別成功,手指抬起后觸發(fā)回調(diào)。 |
onActionCancel(event: () => void) | Rotation手勢識別成功,接收到觸摸取消事件觸發(fā)回調(diào)。 |
- // xxx.ets
- @Entry
- @Component
- struct RotationGestureExample {
- @State angle: number = 0
- @State rotateValue: number = 0
- build() {
- Column() {
- Column() {
- Text('RotationGesture angle:' + this.angle)
- }
- .height(200)
- .width(300)
- .padding(20)
- .border({ width: 3 })
- .margin(80)
- .rotate({ angle: this.angle })
- // 雙指旋轉(zhuǎn)觸發(fā)該手勢事件
- .gesture(
- RotationGesture()
- .onActionStart((event: GestureEvent) => {
- console.info('Rotation start')
- })
- .onActionUpdate((event: GestureEvent) => {
- this.angle = this.rotateValue + event.angle
- })
- .onActionEnd(() => {
- this.rotateValue = this.angle
- console.info('Rotation end')
- })
- )
- }.width('100%')
- }
- }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: