Zepto touch 修复bug

 

Zepto 官方 issues

初步解决方案

百度 GMU上拉滑动实例页面

Fix

https://github.com/madrobby/zepto/issues/315#issuecomment-8386027

touch.js

 

.on('touchmove MSPointerMove pointermove', function(e){
    if((_isPointerType = isPointerEventType(e, 'move')) &&
        !isPrimaryTouch(e)) return
    firstTouch = _isPointerType ? e : e.touches[0]
    cancelLongTap()
    touch.x2 = firstTouch.pageX
    touch.y2 = firstTouch.pageY

    deltaX += Math.abs(touch.x1 - touch.x2)
    deltaY += Math.abs(touch.y1 - touch.y2)

    /**
     * 修复 android 4.4 swipe 事件
     * https://github.com/madrobby/zepto/issues/315#issuecomment-8386027
     */
    if (touch.x2 && Math.abs(touch.x1 - touch.x2) > 10)
        e.preventDefault()
})

 

posted @ 2015-05-11 12:40  赵小磊  阅读(199)  评论(0)    收藏  举报
回到头部