Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

fix touchend trigger bug #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

prianyu
Copy link

@prianyu prianyu commented Jul 3, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant