觸屏事件的簡單描述:
js的觸屏事件,主要有三個事件:touchstart,touchmove,touchend。
這三個事件最重要的屬性是 pageX和 pageY,表示X坐標,Y坐標。
touchstart=在觸摸開始時觸發事件
touchend=在觸摸結束時觸發事件
touchmove=這個事件比較奇怪,按道理在觸摸到過程中不斷激發這個事件才對,但是在我的 Android 1.5 中,在 touchstart 激發后激發一次,然后剩余的都和 touchend 差不多同時激發。
這三個事件都都有一個 timeStamp 的屬性,查看 timeStamp 屬性,可以看到順序是 touchstart -> touchmove ->touchmove -> … -> touchmove ->touchend。
觸屏事件的問題:
如果觸發了 touchmove, touchend 就不會被觸發了, 而且 touchmove 沒有持續觸發。
解決方法:
只要在 touchstart 的時候調用下 event.preventDefault(); 即可讓其他事件都正常被觸發了!
