jQuery 和 jQuery 移动设备:tap 与 touchstart、touchend、touchmove 和 click?
jQuery and jQuery Mobile : tap vs touchstart, touchend, touchmove and click?
jQuery Mobile Tap是否对应于向这样的元素添加事件侦听器:
myElement.addEventListener("touchstart", touchStartHandler, false);
如果是,那剩下的touchmove
、touchend
等正常事件怎么办?我的意思是它们在 jQuery Mobile 中的等价物是什么?
谢谢你的指导。
我不知道他们处理句柄的方式是否完全相同,但他们都等待一个动作然后执行函数。
在 jquery 手机中你可以做到
$("p").on("taphold",function(){
$(this).hide();
});
and
$(function(){
$( "div.box" ).bind( "tap", tapHandler );
function tapHandler( event ){
$( event.target ).addClass( "tap" );
}
});
内部 tap
使用 vclick
。
如果您在此列表中找不到事件,则它们不会以相同的名称公开:https://api.jquerymobile.com/category/events/
这意味着,例如:如果您需要像往常一样处理 touchstart、touchend 和 touchmove,您最终可能会使用虚拟鼠标事件处理程序集:vmousedown, vmousemove, vmouseup
和 vclick
但您可能需要自己处理指针(鼠标或手指)的状态。不要忘记处理 vmousecancel
.
此外,您应该注意等待某些事件会有延迟。
以下是 jQuery 移动文档的简短摘录,其中包含触摸设备(移动或现代混合笔记本电脑)的一些关键概念,需要注意:
Webkit based browsers synthesize mousedown, mouseup, and click events
roughly 300ms after the touchend event is dispatched.
The jQuery Mobile taphold triggers after 750ms.
After 1500ms, then it is not a touch event. Scroll, TouchMove and
TouchEnd events use this. The block list is cleared.
We recommend using click instead of vclick anytime the action being
triggered has the possibility of changing the content underneath the
point that was touched on screen. This includes page transitions and
other behaviors such as collapse/expand that could result in the
screen shifting or content being completely replaced.
祝你有愉快的一天
jQuery Mobile Tap是否对应于向这样的元素添加事件侦听器:
myElement.addEventListener("touchstart", touchStartHandler, false);
如果是,那剩下的touchmove
、touchend
等正常事件怎么办?我的意思是它们在 jQuery Mobile 中的等价物是什么?
谢谢你的指导。
我不知道他们处理句柄的方式是否完全相同,但他们都等待一个动作然后执行函数。 在 jquery 手机中你可以做到
$("p").on("taphold",function(){
$(this).hide();
});
and$(function(){
$( "div.box" ).bind( "tap", tapHandler );
function tapHandler( event ){
$( event.target ).addClass( "tap" );
}
});
内部 tap
使用 vclick
。
如果您在此列表中找不到事件,则它们不会以相同的名称公开:https://api.jquerymobile.com/category/events/
这意味着,例如:如果您需要像往常一样处理 touchstart、touchend 和 touchmove,您最终可能会使用虚拟鼠标事件处理程序集:vmousedown, vmousemove, vmouseup
和 vclick
但您可能需要自己处理指针(鼠标或手指)的状态。不要忘记处理 vmousecancel
.
此外,您应该注意等待某些事件会有延迟。
以下是 jQuery 移动文档的简短摘录,其中包含触摸设备(移动或现代混合笔记本电脑)的一些关键概念,需要注意:
Webkit based browsers synthesize mousedown, mouseup, and click events roughly 300ms after the touchend event is dispatched.
The jQuery Mobile taphold triggers after 750ms.
After 1500ms, then it is not a touch event. Scroll, TouchMove and TouchEnd events use this. The block list is cleared.
We recommend using click instead of vclick anytime the action being triggered has the possibility of changing the content underneath the point that was touched on screen. This includes page transitions and other behaviors such as collapse/expand that could result in the screen shifting or content being completely replaced.
祝你有愉快的一天