Zepto swipe 无效(坑)

Zepto 滑动插件 bug

Zepto 的 'swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown' 触摸事件在安卓4.4系统中除chrome + 火狐 之外的 浏览器 + 微信 都无效

zepto 滑动插件有bug的。。。

而且这个 bug 作者不愿意修,理由是:我特么没有安卓设备

I also can't get all about 'swipe' to work correctly on Android devices. I use a Nexus 4 ,xiaomi 1S 。

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() }) 

你可能感兴趣的:(Zepto swipe 无效(坑))