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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM