Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想找到在移动浏览器中检测滑动事件的 som js 代码。我想在用户滑动时有几个事件,而不是在滑动结束时只有一个事件。有点像用户滚动页面并且触发了许多滚动事件。
有人见过这个吗?
因为没有“滑动”事件,您可能希望监听该"touchend"事件并向其添加事件侦听器。 但是,对于一个全面的触摸界面,您将需要一个更复杂的解决方案,检测正在发生的事情,以 开始"touchstart",以and"touchmove"结束,然后检查它们的距离等等。 所以你最终得到的是所有这些事件的监听器,它记住它的状态并计算距离、时间和方向,然后根据这些计算做出决定。"touchcancel""touchend"
"touchend"
"touchstart"
"touchmove"
"touchcancel"
我知道,这不是一个简单的解决方案。