一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

SwipeGesture和RotationGesture手勢(shì)

ArkUI詳解 ? 2022-12-07 19:24 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

# 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)過程中回調(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)過程中回調(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ī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 手勢(shì)識(shí)別
    +關(guān)注

    關(guān)注

    8

    文章

    227

    瀏覽量

    48278
  • 觸摸
    +關(guān)注

    關(guān)注

    8

    文章

    199

    瀏覽量

    64966
  • OpenHarmony
    +關(guān)注

    關(guān)注

    29

    文章

    3848

    瀏覽量

    18554
  • OpenHarmony3.1
    +關(guān)注

    關(guān)注

    0

    文章

    11

    瀏覽量

    663
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    紅外手勢(shì)識(shí)別方案 紅外手勢(shì)感應(yīng)模塊 紅外識(shí)別紅外手勢(shì)識(shí)別

    紅外手勢(shì)識(shí)別方案,適用于多種領(lǐng)域,如音響,可實(shí)現(xiàn)通過手勢(shì)識(shí)別暫停,開始,上一首,下一首;智能家居,如電動(dòng)窗簾,感應(yīng)馬桶等;電子產(chǎn)品,如臺(tái)燈開關(guān)以及亮度的調(diào)節(jié)。
    發(fā)表于 08-27 16:37

    Android 手勢(shì)識(shí)別

    本帖最后由 kiter_rp 于 2014-9-11 14:23 編輯 總體來分析手勢(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ù)硬件連接庫文件使用其他硬件制作手勢(shì)識(shí)別控
    發(fā)表于 09-07 06:45

    HarmonyOS應(yīng)用API手勢(shì)方法-綁定手勢(shì)方法

    述:為組件綁定不同類型的手勢(shì)事件,并設(shè)置事件的響應(yīng)方法。Api:從API Version 7開始支持一、綁定手勢(shì)識(shí)別:通過如下屬性給組件綁定手勢(shì)識(shí)別,手勢(shì)識(shí)別成功后可以通過事件回調(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開始支持接口: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開始支持接口: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開始支持接口:SwipeGesture(value?: { fingers
    發(fā)表于 12-01 17:29

    HarmonyOS/OpenHarmony(Stage模型)應(yīng)用開發(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)用開發(fā)組合手勢(shì)(三)互斥識(shí)別

    的觸發(fā)條件為滑動(dòng)距離達(dá)到5vp,先達(dá)到觸發(fā)條件的手勢(shì)觸發(fā)。可以通過修改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)確性不高的問題。針對(duì)該問題,提出了一種基于加鎖機(jī)制的靜態(tài)
    發(fā)表于 12-15 13:34 ?0次下載
    基于加鎖機(jī)制的靜態(tài)<b class='flag-5'>手勢(shì)</b>識(shí)別運(yùn)動(dòng)中的<b class='flag-5'>手勢(shì)</b>

    混合交互手勢(shì)模型設(shè)計(jì)

    分析了觸控交互技術(shù)在移動(dòng)手持設(shè)備及可穿戴設(shè)備的應(yīng)用現(xiàn)狀及存在的問題.基于交互動(dòng)作的時(shí)間連續(xù)性及空間連續(xù)性。提出了將觸控交互動(dòng)作的接觸面軌跡與空間軌跡相結(jié)合。同時(shí)具有空中手勢(shì)及觸控手勢(shì)的特性及優(yōu)點(diǎn)
    發(fā)表于 12-26 11:15 ?0次下載
    混合交互<b class='flag-5'>手勢(shì)</b>模型設(shè)計(jì)

    手勢(shì)識(shí)別技術(shù)及其應(yīng)用

    手勢(shì)識(shí)別技術(shù)是一種通過計(jì)算機(jī)視覺和人工智能技術(shù)來分析和識(shí)別人類手勢(shì)動(dòng)作的技術(shù)。它主要利用傳感器、攝像頭等設(shè)備捕捉手勢(shì)信息,然后通過算法對(duì)捕捉到的手勢(shì)信息進(jìn)行處理和分析,從而實(shí)現(xiàn)對(duì)
    的頭像 發(fā)表于 06-14 18:12 ?2848次閱讀

    車載手勢(shì)識(shí)別技術(shù)的原理及其應(yīng)用

    車載手勢(shì)識(shí)別技術(shù)是一種利用計(jì)算機(jī)視覺和人工智能技術(shù)來識(shí)別和理解駕駛員手勢(shì)的技術(shù)。該技術(shù)通過使用傳感器、攝像頭等設(shè)備捕捉駕駛員的手勢(shì)動(dòng)作,然后通過算法對(duì)捕捉到的手勢(shì)動(dòng)作進(jìn)行識(shí)別和分析,以
    的頭像 發(fā)表于 06-27 18:09 ?2056次閱讀

    OpenHarmony實(shí)戰(zhàn)開發(fā)-手勢(shì)事件

    手勢(shì)表示由單個(gè)或多個(gè)事件識(shí)別的語義動(dòng)作(例如:點(diǎn)擊、拖動(dòng)和長按)。一個(gè)完整的手勢(shì)也可能由多個(gè)事件組成,對(duì)應(yīng)手勢(shì)的生命周期。支持的事件有:
    的頭像 發(fā)表于 04-29 13:57 ?588次閱讀

    鴻蒙ArkTS聲明式開發(fā):跨平臺(tái)支持列表RotationGesture之基礎(chǔ)手勢(shì)

    用于觸發(fā)旋轉(zhuǎn)手勢(shì)事件,觸發(fā)旋轉(zhuǎn)手勢(shì)的最少手指為2指,最大為5指,最小改變度數(shù)為1度。
    的頭像 發(fā)表于 06-18 09:27 ?630次閱讀
    鴻蒙ArkTS聲明式開發(fā):跨平臺(tái)支持列表<b class='flag-5'>RotationGesture</b>之基礎(chǔ)<b class='flag-5'>手勢(shì)</b>