我正在尝试为平板电脑实现一个触摸监听器,以触发一些操作,具体取决于触摸是向上还是向下移动。
我尝试了本机监听器:
($document).bind('touchmove', function (e)
{
alert("it worked but i don't know the direction");
});
但我不知道如何确定方向。
这可能吗?
或者我是否需要使用 touchstart/touchend,如果我需要这个,我可以在触摸移动停止之前确定方向吗?
如果我只能使用外部库来做到这一点,那么最好的是什么?
thanks.
我在 iPad 上遇到了一些问题,并通过两个事件解决了它
var ts;
$(document).bind('touchstart', function (e){
ts = e.originalEvent.touches[0].clientY;
});
$(document).bind('touchend', function (e){
var te = e.originalEvent.changedTouches[0].clientY;
if(ts > te+5){
slide_down();
}else if(ts < te-5){
slide_up();
}
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)