0

关于如何在手机/平板电脑上触发滚动事件(中滚动)也有类似的问题。我已经使用了下面提供的代码,但我还没有让它在 chrome 模拟器中工作。

$('body').on({
   'touchmove': function(e) {
       console.log($(this).scrollTop()); // Replace this with your code.
    }
});

当我使用触摸传感器而不是 touchmove 滚动时,touchstart 将记录。我错过了什么?

4

2 回答 2

1

在此处输入图像描述您是否启用了“模拟触摸屏”?

检查“传感器”中的此链接 http://www.sitepoint.com/use-mobile-emulation-mode-chrome/


试试这个代码

<script type="text/javascript">
 $(document).bind('touchmove', function(e) {
   console.log($(this).scrollTop()); 
 });
</script>
于 2015-03-27T13:53:24.430 回答
0

我使用bindand originalEvent,它适用于真实的移动设备:

    $("html").bind("touchmove", function(e)
    {
        e.preventDefault();
        var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
        var x = touch.pageX, y =touch.pageY;
于 2017-11-08T19:12:55.573 回答