移动端事件
触摸事件touch
屏幕触摸事件,PC端的鼠标移动时是无效的,模拟器时,鼠标点击就会变成触摸事件。允许多点触控,事件触发的位置就在touches属性。
var body = document.querySelector('body');
//触摸开始事件
body.ontouchstart = function (event) {
console.log(event);
console.log('触摸开始事件');
};
//触摸移动事件
body.ontouchmove = function (event) {
console.log(event);
console.log('触摸移动事件');
};
// 触摸结束事件
body.ontouchend = function (event) {
console.log(event);
console.log('触摸结束事件');
};
//点击事件
body.onclick =function (ev) {
console.log(ev);
console.log('点击事件');
}
1、重点掌握三个touch事件
2、touch事件想要获取触碰的位置需要再touches里面获取
3、如何判断触碰事件是什么方向滑动
4理解掌握如何将滑动事件封装到对象中。