作者:feix760
1、首先随意的滑两次,每次滑长一些,不用滑重(碎屏就不好了~~)
2、再点击一次,之后立刻停住~
Oh, no 你肯定在我说停住之后再点了一下,你觉得你并没有点到~
反复试几次仔细发现,原来是要点两次!
$(document)
.on('touchstart', function() {
// 打酱油
})
.on('touchmove', function() {
deltaX += XXX;
deltaY += XXX;
})
.on('touchend', function() {
if (deltaX < 30 && deltaY < 30) {
// you tap me
touch.el && touch.el.trigger(event)
}
deltaX = deltaY = 0;
})
.on('touchcancel', function() {
// 打酱油
});
长距离的滑动: touchstart - > touchmove(仅一次) -> touchcancel
短距离: touchstart - > touchmove(一次) -> touchend
事情发展到了这里,去下载最新的zepto发现也只在touchend里做了这件重要的事情
deltaX = deltaY = 0;
哎~
Android 4.4 长距离的滑动touchmove只发生一次是不是让充满爱的FE瞬间变得忧伤了~
哈~,其实只需touchmove时e.preventDefault()
touchstart - > touchmove(仅一次) -> touchcancel
就能变成
touchstart - > touchmove(多次) -> touchend
(也不再是touchcancel了)
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有