移动端(手机和平板)和PC端事件不同。PC端click事件的 300ms 的延迟在移动端不适用。移动端中,不管开发APP还是网页,都需要使用不同的事件和处理方法。
指针事件
指针事件合并了触摸和鼠标操作,它的必要性在于有一些超极本、平板电脑(Surface系列)同时支持触摸和鼠标操作,并且需要在两者间进行无缝的切换。
-
pointerdown
-
pointermove
-
pointerup
-
pointerover
-
pointerout
触摸事件
移动浏览器同时支持触摸事件和鼠标事件,会导致一个触摸动作触发多个事件。
-
触摸(Tap):touchstart/pointerdown、touchend/pointerup、mouseover、mousemove、mousedown、mouseup、click、:hover样式(需要注意的是为了兼容mouseover,抬起手指并不会触发mouseout,再次触摸才会)
-
滑动(Swipe):touchstart、touchmove、touchend、scroll
-
缩放(Pinch):touchstart、touchmove、touchend、scroll,可能还有resize
-
双触(double-tap):touchstart、两次touchend、scroll,可能还有resize
-
按住(touchhold):touchstart、touchend,有些浏览器还有contextmenu
PC端click事件的局限性
300毫秒延迟问题。(Chrome支持但苹果不能支持)