码迷,mamicode.com
首页 > 微信 > 详细

Zepto swipe 在安卓、微信 无效的解决方法

时间:2015-10-24 17:09:57      阅读:1261      评论:0      收藏:0      [点我收藏+]

标签:

做公司的一个手机站,发现zepto的touch.js在安卓上的兼容性有bug,主要是在微信上无法触发swipe*事件,而且这个 bug 作者不愿意修,理由是:我特么没有安卓设备。发生这种bug的原因大概是安卓设备上

网上找到了一个大神的初步解决方案:在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()
      })

点击原因及进一步fix  

Zepto swipe 在安卓、微信 无效的解决方法

标签:

原文地址:http://www.cnblogs.com/vincent2d/p/4907090.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!