ios触摸事件
See more on JavaScript events
进一步了解JavaScript事件
Touch events are those events that are triggered when viewing the page on a mobile device, like a smartphone or a tablet.
触摸事件是在智能手机或平板电脑等移动设备上查看页面时触发的事件。
They allow you to track multitouch events.
它们使您可以跟踪多点触控事件。
We have 4 touch events:
我们有4个触摸事件:
touchstart
a touch event has started (the surface is touched)touchstart
触摸事件已开始(已触摸表面)touchend
a touch event has ended (the surface is no longer touched)touchend
触摸事件已结束(不再触摸表面)touchmove
the finger (or whatever is touching the device) moves over the surfacetouchmove
手指(或触摸设备的任何物体)在表面上移动touchcancel
the touch event has been cancelledtouchcancel
触摸事件已取消
Every time a touch event occurs we are passed a touch event:
每次发生触摸事件时,我们都会通过一个触摸事件 :
const link = document.getElementById('my-link')
link.addEventListener('touchstart', event => {
// touch event started
})
Here are all the properties we can access on that event
这是我们可以在该事件上访问的所有属性
identifier
an unique identifier for this specific event. Used to track multi-touch events. Same finger = same identifier.identifier
此特定事件的唯一标识符。 用于跟踪多点触控事件。 同一根手指=相同的标识符。clientX
/clientY
the x and y coordinates of the mouse pointer relative to the browser window, regardless of scrollingclientX
/clientY
鼠标指针相对于浏览器窗口的x和y坐标,与滚动无关screenX
/screenY
the x and y coordinates of the mouse pointer in the screen coordinatesscreenX
/screenY
屏幕坐标中鼠标指针的x和y坐标pageX
/pageY
the x and y coordinates of the mouse pointer in the page coordinates (including scrolling)pageX
/pageY
页面坐标中鼠标指针的x和y坐标(包括滚动)target
the element touchedtarget
感动元素
ios触摸事件