AlloyFinger
AlloyFinger copied to clipboard
tap和singleTap 有什么区别?
this.tapTimeout = setTimeout(function () {
self.tap(evt);
// trigger double tap immediately
if (self.isDoubleTap) {
self.doubleTap(evt);
clearTimeout(self.touchTimeout);
self.isDoubleTap = false;
}else{
self.touchTimeout=setTimeout(function(){
self.singleTap(evt);
},250);
}
}, 0)
看了源码一个是马上触发,一个要250,有啥用?为什么不统一就用一种?
singleTap约等于click @MeCKodo
@dntzhang 想请教个问题,在看源码的时候发现这段代码
if (len > 1) {
var v = { x: evt.touches[1].pageX - currentX, y: evt.touches[1].pageY - currentY };
if (preV.x !== null) {
if (this.pinchStartLen > 0) {
evt.scale = getLen(v) / this.pinchStartLen;
this.pinch.dispatch(evt);
}
evt.angle = getRotateAngle(v, preV);
this.rotate.dispatch(evt);
}
preV.x = v.x;
preV.y = v.y;
}
- 为什么要判断preV是否存在呢?当多点触摸的时候,在start阶段,应该就肯定会设置preV值了
- 同理,pinchStartLen也是肯定会有的,如果是多点触摸的话。 所以,就感觉这两个地方的条件判断是否有点多余啊?
仔细读了一遍代码。preV.x!==null的判断确实多余了。pinchStartLen 是代表两个手指的距离,大于0的判断还是要的