Javascript 使用SnapSvg切换到触摸事件
我需要为触摸屏使用触摸事件,为我的网站使用Snap SVG的常规桌面使用鼠标事件 我有如下鼠标事件:Javascript 使用SnapSvg切换到触摸事件,javascript,snap.svg,Javascript,Snap.svg,我需要为触摸屏使用触摸事件,为我的网站使用Snap SVG的常规桌面使用鼠标事件 我有如下鼠标事件: _Button.mousedown(function(){ // Do Stuff }); 当我的用户来自平板电脑时,如何轻松切换到触摸事件,如“touchstart” 我不想重复代码,并检查它是否是触摸屏,比如有20*倍的这种代码: _Button.mousedown(function(){ // Do Stuff }); if ( touchSreenFlag === t
_Button.mousedown(function(){
// Do Stuff
});
当我的用户来自平板电脑时,如何轻松切换到触摸事件,如“touchstart”
我不想重复代码,并检查它是否是触摸屏,比如有20*倍的这种代码:
_Button.mousedown(function(){
// Do Stuff
});
if ( touchSreenFlag === true) {
_Button.mousedown(function(){
// Do Stuff
});
}
Thx我们开始:
SVGTHING.mouseup(function(e){
if (e.type === 'touchend') {
// Stop propagation : on touch devices the first click will be used and not the second.
e.stopPropagation();
e.preventDefault();
}
do_stuff();
});
Mousedown事件在ios上触发两次。