1 Star 0 Fork 5.2K

OpenHarmony-build / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ts-basic-gestures-pinchgesture.md 6.44 KB
一键复制 编辑 原始数据 按行查看 历史
zengyawen 提交于 2021-11-10 20:02 . add arkui

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')
        })
    )
  }
}

1
https://gitee.com/openharmony-build/docs.git
git@gitee.com:openharmony-build/docs.git
openharmony-build
docs
docs
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891