# SwipeGesture
用于觸發(fā)滑動(dòng)事件,滑動(dòng)速度大于100vp/s時(shí)可識(shí)別成功。
| 參數(shù)名稱 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
|---|---|---|---|
| fingers | number | 否 | 觸發(fā)滑動(dòng)的最少手指數(shù),默認(rèn)為1,最小為1指,最大為10指。 默認(rèn)值:1 |
| direction | SwipeDirection | 否 | 觸發(fā)滑動(dòng)手勢(shì)的滑動(dòng)方向。 默認(rèn)值:SwipeDirection.All |
| speed | number | 否 | 識(shí)別滑動(dòng)的最小速度(默認(rèn)為100VP/秒)。 默認(rèn)值:100 |
SwipeDirection的三個(gè)枚舉值
declare enum SwipeDirection {
/**
* Default.
* @since 8
*/
None,
/**
* Sliding horizontally.
* @since 8
*/
Horizontal,
/**
* Sliding Vertical
* @since 8
*/
Vertical,
/**
* Sliding in all directions.
* @since 8
*/
All
}
- All:所有方向。
- Horizontal:水平方向,手指滑動(dòng)方向與x軸夾角小于45度時(shí)觸發(fā)。
- Vertical:豎直方向,手指滑動(dòng)方向與y軸夾角小于45度時(shí)觸發(fā)。
- None:任何方向均不可觸發(fā)。
事件
* Slide gesture recognition success callback.
* @since 8
*/
onAction(event: (event?: GestureEvent) => void): SwipeGestureInterface;
完整代碼
@Entry
@Component
struct SwipeGestureExample {
@State rotateAngle: number = 0
@State speed: number = 1
?
build() {
Column() {
Column() {
Text("滑動(dòng) 速度" + this.speed)
Text("滑動(dòng) 角度" + this.rotateAngle)
}
.border({ width: 3 })
.width(300)
.height(200)
.margin(100)
.rotate({
?
?
angle: this.rotateAngle,})
// 單指豎直方向滑動(dòng)時(shí)觸發(fā)該事件
.gesture(
SwipeGesture({
fingers:2,
direction: SwipeDirection.All })
.onAction((event: GestureEvent) => {
this.speed = event.speed
this.rotateAngle = event.angle
})
)
}.width('100%')
}
}
RotationGesture
用于觸發(fā)旋轉(zhuǎn)手勢(shì)事件,觸發(fā)旋轉(zhuǎn)手勢(shì)的最少手指為2指,最大為5指,最小改變度數(shù)為1度。
| 數(shù)名稱 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
|---|---|---|---|
| fingers | number | 否 | 觸發(fā)旋轉(zhuǎn)的最少手指數(shù), 最小為2指,最大為5指。 默認(rèn)值:2 |
| angle | number | 否 | 觸發(fā)旋轉(zhuǎn)手勢(shì)的最小改變度數(shù),單位為deg。 默認(rèn)值:1 |
提供了四種事件
事件
- ** onActionStart(event: (event?: GestureEvent) => void):Rotation手勢(shì)識(shí)別成功回調(diào)。**
- onActionUpdate(event: (event?: GestureEvent) => void):Rotation手勢(shì)移動(dòng)過(guò)程中回調(diào)。
- ** onActionEnd(event: (event?: GestureEvent) => void):Rotation手勢(shì)識(shí)別成功,手指抬起后觸發(fā)回調(diào)。**
- ** onActionCancel(event: () => void):Rotation手勢(shì)識(shí)別成功,接收到觸摸取消事件觸發(fā)回調(diào)。**
* Pan gesture recognition success callback.
* @since 7
*/
onActionStart(event: (event?: GestureEvent) => void): RotationGestureInterface;
/**
* Callback when the Pan gesture is moving.
* @since 7
*/
onActionUpdate(event: (event?: GestureEvent) => void): RotationGestureInterface;
/**
* The Pan gesture is successfully recognized. When the finger is lifted, the callback is triggered.
* @since 7
*/
onActionEnd(event: (event?: GestureEvent) => void): RotationGestureInterface;
/**
* The Pan gesture is successfully recognized and a callback is triggered when the touch cancel event is received.
* @since 7
*/
onActionCancel(event: () => void): RotationGestureInterface;
}
完整代碼:
// xxx.ets
@Entry
@Component
struct RotationGestureExample {
@State angle: number = 0
@State rotateValue: number = 0
?
build() {
Column() {
Column() {
Text('旋轉(zhuǎn)角度:' + this.angle)
}
.height(200)
.width(300)
.padding(20)
.border({ width: 3 })
.margin(80)
.rotate({ angle: this.angle })
// 雙指旋轉(zhuǎn)觸發(fā)該手勢(shì)事件
.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')
}).onActionCancel(()=>{
console.info('Rotation onActionCancel')
})
)
}.width('100%')
}
}
用于觸發(fā)滑動(dòng)事件,滑動(dòng)速度大于100vp/s時(shí)可識(shí)別成功。
| 參數(shù)名稱 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
|---|---|---|---|
| fingers | number | 否 | 觸發(fā)滑動(dòng)的最少手指數(shù),默認(rèn)為1,最小為1指,最大為10指。 默認(rèn)值:1 |
| direction | SwipeDirection | 否 | 觸發(fā)滑動(dòng)手勢(shì)的滑動(dòng)方向。 默認(rèn)值:SwipeDirection.All |
| speed | number | 否 | 識(shí)別滑動(dòng)的最小速度(默認(rèn)為100VP/秒)。 默認(rèn)值:100 |
SwipeDirection的三個(gè)枚舉值
declare enum SwipeDirection {
/**
* Default.
* @since 8
*/
None,
/**
* Sliding horizontally.
* @since 8
*/
Horizontal,
/**
* Sliding Vertical
* @since 8
*/
Vertical,
/**
* Sliding in all directions.
* @since 8
*/
All
}
- All:所有方向。
- Horizontal:水平方向,手指滑動(dòng)方向與x軸夾角小于45度時(shí)觸發(fā)。
- Vertical:豎直方向,手指滑動(dòng)方向與y軸夾角小于45度時(shí)觸發(fā)。
- None:任何方向均不可觸發(fā)。
事件
* Slide gesture recognition success callback.
* @since 8
*/
onAction(event: (event?: GestureEvent) => void): SwipeGestureInterface;
完整代碼
@Entry
@Component
struct SwipeGestureExample {
@State rotateAngle: number = 0
@State speed: number = 1
?
build() {
Column() {
Column() {
Text("滑動(dòng) 速度" + this.speed)
Text("滑動(dòng) 角度" + this.rotateAngle)
}
.border({ width: 3 })
.width(300)
.height(200)
.margin(100)
.rotate({
?
?
angle: this.rotateAngle,})
// 單指豎直方向滑動(dòng)時(shí)觸發(fā)該事件
.gesture(
SwipeGesture({
fingers:2,
direction: SwipeDirection.All })
.onAction((event: GestureEvent) => {
this.speed = event.speed
this.rotateAngle = event.angle
})
)
}.width('100%')
}
}
RotationGesture
用于觸發(fā)旋轉(zhuǎn)手勢(shì)事件,觸發(fā)旋轉(zhuǎn)手勢(shì)的最少手指為2指,最大為5指,最小改變度數(shù)為1度。
| 數(shù)名稱 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
|---|---|---|---|
| fingers | number | 否 | 觸發(fā)旋轉(zhuǎn)的最少手指數(shù), 最小為2指,最大為5指。 默認(rèn)值:2 |
| angle | number | 否 | 觸發(fā)旋轉(zhuǎn)手勢(shì)的最小改變度數(shù),單位為deg。 默認(rèn)值:1 |
提供了四種事件
事件
- ** onActionStart(event: (event?: GestureEvent) => void):Rotation手勢(shì)識(shí)別成功回調(diào)。**
- onActionUpdate(event: (event?: GestureEvent) => void):Rotation手勢(shì)移動(dòng)過(guò)程中回調(diào)。
- ** onActionEnd(event: (event?: GestureEvent) => void):Rotation手勢(shì)識(shí)別成功,手指抬起后觸發(fā)回調(diào)。**
- ** onActionCancel(event: () => void):Rotation手勢(shì)識(shí)別成功,接收到觸摸取消事件觸發(fā)回調(diào)。**
* Pan gesture recognition success callback.
* @since 7
*/
onActionStart(event: (event?: GestureEvent) => void): RotationGestureInterface;
/**
* Callback when the Pan gesture is moving.
* @since 7
*/
onActionUpdate(event: (event?: GestureEvent) => void): RotationGestureInterface;
/**
* The Pan gesture is successfully recognized. When the finger is lifted, the callback is triggered.
* @since 7
*/
onActionEnd(event: (event?: GestureEvent) => void): RotationGestureInterface;
/**
* The Pan gesture is successfully recognized and a callback is triggered when the touch cancel event is received.
* @since 7
*/
onActionCancel(event: () => void): RotationGestureInterface;
}
完整代碼:
// xxx.ets
@Entry
@Component
struct RotationGestureExample {
@State angle: number = 0
@State rotateValue: number = 0
?
build() {
Column() {
Column() {
Text('旋轉(zhuǎn)角度:' + this.angle)
}
.height(200)
.width(300)
.padding(20)
.border({ width: 3 })
.margin(80)
.rotate({ angle: this.angle })
// 雙指旋轉(zhuǎn)觸發(fā)該手勢(shì)事件
.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')
}).onActionCancel(()=>{
console.info('Rotation onActionCancel')
})
)
}.width('100%')
}
}
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。
舉報(bào)投訴
-
手勢(shì)識(shí)別
+關(guān)注
關(guān)注
8文章
232瀏覽量
49128 -
觸摸
+關(guān)注
關(guān)注
8文章
200瀏覽量
65784 -
OpenHarmony
+關(guān)注
關(guān)注
33文章
3952瀏覽量
21104 -
OpenHarmony3.1
+關(guān)注
關(guān)注
0文章
11瀏覽量
698
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
熱點(diǎn)推薦
紅外手勢(shì)識(shí)別方案 紅外手勢(shì)感應(yīng)模塊 紅外識(shí)別紅外手勢(shì)識(shí)別
紅外手勢(shì)識(shí)別方案,適用于多種領(lǐng)域,如音響,可實(shí)現(xiàn)通過(guò)手勢(shì)識(shí)別暫停,開(kāi)始,上一首,下一首;智能家居,如電動(dòng)窗簾,感應(yīng)馬桶等;電子產(chǎn)品,如臺(tái)燈開(kāi)關(guān)以及亮度的調(diào)節(jié)。
發(fā)表于 08-27 16:37
Android 手勢(shì)識(shí)別
本帖最后由 kiter_rp 于 2014-9-11 14:23 編輯
總體來(lái)分析手勢(shì)有關(guān)涉及到手勢(shì)匹配相關(guān)的源碼類之間的關(guān)系,如下圖: 上圖中的相關(guān)類簡(jiǎn)介:GestureLibrary:手勢(shì)
發(fā)表于 09-11 14:22
手勢(shì)識(shí)別控制器制作
目錄智能家居硬件小制作(含源碼)《手勢(shì)識(shí)別控制器》基于PAJ7620手勢(shì)模塊、L298N驅(qū)動(dòng)板、arduino介紹材料PAJ7620手勢(shì)模塊參數(shù)硬件連接庫(kù)文件使用其他硬件制作手勢(shì)識(shí)別控
發(fā)表于 09-07 06:45
HarmonyOS應(yīng)用API手勢(shì)方法-綁定手勢(shì)方法
述:為組件綁定不同類型的手勢(shì)事件,并設(shè)置事件的響應(yīng)方法。Api:從API Version 7開(kāi)始支持一、綁定手勢(shì)識(shí)別:通過(guò)如下屬性給組件綁定手勢(shì)識(shí)別,手勢(shì)識(shí)別成功后可以通過(guò)事件回調(diào)通知
發(fā)表于 11-23 15:53
HarmonyOS應(yīng)用API手勢(shì)方法-RotationGesture
描述:用于觸發(fā)旋轉(zhuǎn)手勢(shì)事件,觸發(fā)旋轉(zhuǎn)手勢(shì)的最少手指為2指,最大為5指,最小改變度數(shù)為1度。Api:從API Version 7開(kāi)始支持接口:RotationGesture(value?: &
發(fā)表于 11-30 10:42
HarmonyOS應(yīng)用API手勢(shì)方法-RotationGesture
描述:用于觸發(fā)旋轉(zhuǎn)手勢(shì)事件,觸發(fā)旋轉(zhuǎn)手勢(shì)的最少手指為2指,最大為5指,最小改變度數(shù)為1度。Api:從API Version 7開(kāi)始支持接口:RotationGesture(value?: &
發(fā)表于 11-30 10:43
HarmonyOS應(yīng)用API手勢(shì)方法-SwipeGesture
描述:用于觸發(fā)滑動(dòng)事件,滑動(dòng)最小速度為100vp/s時(shí)識(shí)別成功。Api:從API Version 8開(kāi)始支持接口:SwipeGesture(value?: { fingers
發(fā)表于 12-01 17:29
HarmonyOS/OpenHarmony(Stage模型)應(yīng)用開(kāi)發(fā)單一手勢(shì)(三)
五、旋轉(zhuǎn)手勢(shì)(RotationGesture)
.RotationGesture(value?:{fingers?:number; angle?:number})
旋轉(zhuǎn)手勢(shì)用于觸發(fā)旋轉(zhuǎn)
發(fā)表于 09-06 14:14
HarmonyOS/OpenHarmony(Stage模型)應(yīng)用開(kāi)發(fā)組合手勢(shì)(三)互斥識(shí)別
的觸發(fā)條件為滑動(dòng)距離達(dá)到5vp,先達(dá)到觸發(fā)條件的手勢(shì)觸發(fā)??梢酝ㄟ^(guò)修改SwipeGesture和PanGesture的參數(shù)以達(dá)到不同的效果。
發(fā)表于 09-11 15:01
基于加鎖機(jī)制的靜態(tài)手勢(shì)識(shí)別運(yùn)動(dòng)中的手勢(shì)
基于 RGB-D( RGB-Depth)的靜態(tài)手勢(shì)識(shí)別的速度高于其動(dòng)態(tài)手勢(shì)識(shí)別,但是存在冗余手勢(shì)和重復(fù)手勢(shì)而導(dǎo)致識(shí)別準(zhǔn)確性不高的問(wèn)題。針對(duì)該問(wèn)題,提出了一種基于加鎖機(jī)制的靜態(tài)
發(fā)表于 12-15 13:34
?0次下載
混合交互手勢(shì)模型設(shè)計(jì)
分析了觸控交互技術(shù)在移動(dòng)手持設(shè)備及可穿戴設(shè)備的應(yīng)用現(xiàn)狀及存在的問(wèn)題.基于交互動(dòng)作的時(shí)間連續(xù)性及空間連續(xù)性。提出了將觸控交互動(dòng)作的接觸面軌跡與空間軌跡相結(jié)合。同時(shí)具有空中手勢(shì)及觸控手勢(shì)的特性及優(yōu)點(diǎn)
發(fā)表于 12-26 11:15
?0次下載
手勢(shì)識(shí)別技術(shù)及其應(yīng)用
手勢(shì)識(shí)別技術(shù)是一種通過(guò)計(jì)算機(jī)視覺(jué)和人工智能技術(shù)來(lái)分析和識(shí)別人類手勢(shì)動(dòng)作的技術(shù)。它主要利用傳感器、攝像頭等設(shè)備捕捉手勢(shì)信息,然后通過(guò)算法對(duì)捕捉到的手勢(shì)信息進(jìn)行處理和分析,從而實(shí)現(xiàn)對(duì)
車載手勢(shì)識(shí)別技術(shù)的原理及其應(yīng)用
車載手勢(shì)識(shí)別技術(shù)是一種利用計(jì)算機(jī)視覺(jué)和人工智能技術(shù)來(lái)識(shí)別和理解駕駛員手勢(shì)的技術(shù)。該技術(shù)通過(guò)使用傳感器、攝像頭等設(shè)備捕捉駕駛員的手勢(shì)動(dòng)作,然后通過(guò)算法對(duì)捕捉到的手勢(shì)動(dòng)作進(jìn)行識(shí)別和分析,以
OpenHarmony實(shí)戰(zhàn)開(kāi)發(fā)-手勢(shì)事件
手勢(shì)表示由單個(gè)或多個(gè)事件識(shí)別的語(yǔ)義動(dòng)作(例如:點(diǎn)擊、拖動(dòng)和長(zhǎng)按)。一個(gè)完整的手勢(shì)也可能由多個(gè)事件組成,對(duì)應(yīng)手勢(shì)的生命周期。支持的事件有:
鴻蒙ArkTS聲明式開(kāi)發(fā):跨平臺(tái)支持列表RotationGesture之基礎(chǔ)手勢(shì)
用于觸發(fā)旋轉(zhuǎn)手勢(shì)事件,觸發(fā)旋轉(zhuǎn)手勢(shì)的最少手指為2指,最大為5指,最小改變度數(shù)為1度。
SwipeGesture和RotationGesture手勢(shì)
評(píng)論