移动事件(touchstart touchmove touchend )、
移动事件是什么:
触摸事件
手势活动
传感器事件
(后面两个兼容性不太好,重点是触摸事件。)
触摸事件:
触摸事件
pointer事件
(PC端有时使用jQuery制作视频,但移动端一般做不到。 基本上使用css3制作视频)
ontouchstart (必须在元素中才能触发) )。
ontouchmove (可在元素内部和外部触发) ) ) ) ) )。
ontouchend (可以在元素内部和外部触发)。
ontouchcancel触摸中断经常用于系统级处理,如触摸时突然接电话(通常几乎不可用)。
建议使用“addEventListener”绑定事件,除非出于兼容性原因使用on
触摸
width:200px;
height:200px;
后台: pink;
margin :20 px自动;
}
varbox=document.getelementbyid (' box ); //box.ontouchstart=handleStart;
//box.ontouchmove=handleMove;
//box.ontouchend=handleEnd;
box.addevent listener (' touch start ',handleStart,false );
box.addevent listener (' touch move ',handleMove,false );
box.addeventlistener('touchend ',handleEnd,false ); 功能手动启动
控制台. log (touch start );
}functionhandleMove (() ) )。
控制台. log (touch move );
}functionhandleEnd
控制台. log (touchend );
}
touch事件的事件对象
比较重要的属性
type:'touchstart '触发的事件
target:div#box.box触控元素
更改touches 3360 touch list { 0: touch,length:1}变化的触摸点
目标touches : touch list目标元素上的触摸点
touches : touch list { 0: touch,length:1}所有触点
触摸
}