【问题标题】:Scroll event on touchmove with jquery使用jquery在touchmove上滚动事件
【发布时间】:2012-02-24 10:49:14
【问题描述】:

我目前正在研究使用 $(window).bind('scroll' 的东西,但我遇到的问题是,在 iPad 和其他触摸设备上,只有当用户停止移动并移开手指时才会触发滚动事件. 我尝试过使用 touchmove,但无法弄清楚如何准确获取 $(window).scrollTop()。有人有什么想法吗?

【问题讨论】:

标签: jquery ipad scroll touch


【解决方案1】:


See this answer for reference

虽然以下两种方法都应该有效,但首选方法是...

...对于 Jquery 1.7 及更高版本:

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

...或更早

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

请注意:“这应该会在用户滚动时为您提供一致的 scrollTop 值流,但要小心,因为即使用户只是将手指放在屏幕上,它也会触发。”

【讨论】:

  • 如何触发滚动或 touchmove 但不能同时触发?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-31
  • 2021-08-18
  • 1970-01-01
相关资源
最近更新 更多