slide-view icon indicating copy to clipboard operation
slide-view copied to clipboard

fix touchend trigger bug

Open prianyu opened this issue 6 years ago • 0 comments

touchend事件处理的bug

当滑动listview后,再滑动回初始状态时,由于在onChange处理方法中有以下代码:

  if (!this.data.out && e.detail.x < -this._threshold) {
    /...
   } else if (this.data.out && e.detail.x >= -this._threshold) {
       this.setData({
        out: false
      })
   }

而在onTouchEnd中有如下语句:

if (_endX > _startX && this.data.out === false ) return

这将导致往回滑动时,无法走下面的分支,效果如下:

https://github.com/prianyu/slide-view/blob/master/docs/0.gif

上面的判断条件应该为当满足这里两个条件的同时,满足当前slide滑动的距离为0

if (_endX > _startX && this.data.out === false && this.data.x === 0) return

修改后效果如下:

https://github.com/prianyu/slide-view/blob/master/docs/1.gif

prianyu avatar Jul 03 '19 07:07 prianyu