jQuery touchmove不在chrome模拟器中注册 [英] jQuery touchmove not registering in chrome emulator
本文介绍了jQuery touchmove不在chrome模拟器中注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
关于如何在移动设备/平板电脑上触发滚动事件(中间滚动),也存在类似的问题。我已经使用了下面提供的代码,但是我还没有在chrome模拟器中使用它。
There's been similar questions on how to fire scroll events (mid-scroll) on mobile/tablet. I've used the code provided below but I've yet to get this to work in chrome emulator.
$('body').on({
'touchmove': function(e) {
console.log($(this).scrollTop()); // Replace this with your code.
}
});
当我使用触摸传感器进行滚动但不能触摸移动时,touchstart会记录日志。我缺少什么?
touchstart will log when I scroll with the touch sensor but not touchmove. What am I missing?
推荐答案
我使用 bind
和 originalEvent
,它适用于真正的移动设备:
I use bind
and originalEvent
, which works on real mobile device:
$("html").bind("touchmove", function(e)
{
e.preventDefault();
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
var x = touch.pageX, y =touch.pageY;
这篇关于jQuery touchmove不在chrome模拟器中注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文