<live-player>组件对touch的响应事件数据似乎不正确
发布于 5 年前 作者 guiying44 13413 次浏览 来自 官方Issues

问题:<live-player>上绑定touch事件有bug吧?

<live-player capture-bind:touchstart='onTouchStart' capture-catch:touchmove='onTouchMove' ></live-player>

onTouchStart:function(e) {
    if (e.touches.length == 1) {
      console.log('单指 touch start');
    } else {
      console.log('双指+ touch start');
      console.log(e);
    }
  },
onTouchMove:function(e){
  if (e.touches.length === 1) {
      console.log('单指 touch move');
  } else {
      console.log('双指+ touch move, 手指数量:', e.touches.length);
      if (e.touches.length != 2) {
        console.log(e);
        console.warn('手指数量怎么会这么多?!');
        return;
      }
      if (e.touches[0].clientX == e.touches[1].clientX && e.touches[0].clientY == e.touches[1].clientY ) {
        console.error('两根手指的坐标完全一样!');
        console.log(e);
        return;
      }
  }
 
},

touch相关事件绑定在view上ok:

但在<live-player>上时,两个手指放上去经常会出现"两个手指坐标相同"、“多个touches”!


2 回复

非同层的原生组件组件不支持touchstart等触摸相关事件

猜测是绑定touch事件的元素,其children不能是<live-player>、<cover-view>。

  • <view>  // 在此绑定可以正确响应双指操作

  • <image>

--------------------------------------------------------------------------------------------------------------------------------

+<view> // 在此绑定,双指触发touchstart/touchmove时,touches数组中的identifier相同

  • <live-player>

尚待确认。

回到顶部