我正在开发一个基于触摸的 JS 应用程序,我研究了 Flex 和 Royal 滑块作为示例。我注意到两个滑块在获取touchmove
事件时的行为相似:
var started,touched ;
el.bind('touchstart',function(e){
started = Number(new Date()) ;
// Get pageX and pageY etc...
}) ;
el.bind('touchmove',function(e){
touched = Number(new Date()) ;
if (started-touched > 500) {
// Handle touch moves etc...
}
}) ;
没有这些,我的 JS 应用程序可以无缝运行,但为什么他们需要这样做呢?为什么他们要等待 500 毫秒才能获取移动数据?