Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么要从第二次move开始算delta #114

Open
yuqianma opened this issue Jun 12, 2018 · 3 comments
Open

为什么要从第二次move开始算delta #114

yuqianma opened this issue Jun 12, 2018 · 3 comments

Comments

@yuqianma
Copy link
Contributor

感谢你精巧的手势库
问题:

if (this.x2 !== null) {

在第一次move时这里是null,delta置0。
但是第一次move和start之间也是有delta的。为什么不把start看作move的上一次事件,从第一次move就计算delta?

影响:比如在pressMove这里扩展panStartpan事件,panStart可以通过判断delta方向决定preventDefault。在chrome上,一旦没有在第一个move阻止滚动,后面就会有cancelable = false

@dntzhang
Copy link

dntzhang commented Jun 13, 2018

你的意思是把

evt.deltaX = 0;
evt.deltaY = 0;

改成:

evt.deltaX = current - this.x1;
evt.deltaY = current - this.y1;

是吗?

@yuqianma
Copy link
Contributor Author

呃对,这样改动是最小的。
其实我直接在start里面x2 = x1; y2 = y1了。暂时我只用到单指,多指逻辑还没考虑。
我是想问把start作为move的上一次事件有什么问题吗?觉得这样更顺一点。还不用null判断。

另外看到

if (preV.x !== null) {

这个在end时候置0,实际也只有第一次跳过null了,null判断也比较多余。
this.preV.x = 0;

所以想问,把start作为move上次事件写是不是更好?或者多指有什么考虑?

@dntzhang
Copy link

欢迎pr

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

No branches or pull requests

2 participants