Ets 手势问题, PanGesture与PinchGesture 如何监听平移方向与捏合是外扩,还是内缩?

PanGesture如何监听平移方向

PinchGesture 如何能知道捏合是外扩,还是内缩

有没有大佬知道如何操作,api里没有明确说明


鸿蒙
Ets
PanGesture
2022-10-28 15:10:45
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
ohohy
2

1、PanGesture中有onActionUpdate方法,可以通过这个方法的参数中获取,   这里的offsetX往左移动为负,offsetY往上移动为负,根据这两个参数的正负可以判断平移方向。

2、同理,PinchGesture有onActionUpdate方法,通过event.scale参数判断外扩和内缩

PinchGesture()
  .onActionUpdate((event: GestureEvent) => {
    console.log(event.scale) 
  })

PanGesture({})
  .onActionUpdate((event: GestureEvent) => {
    console.log(`${event.offsetX}`)
    console.log(`${event.offsetY}`)
  })
分享
微博
QQ
微信
回复
2022-10-28 16:16:22
提问
该提问已有0人参与 ,帮助了0人