简体   繁体   中英

android 2.2 browser dont work pageY or PageX in ontouchend event

I have a web app that work perfect in android 2.1, when I upgrade to 2.2 the pageX property in ontouchend event, this is my code:

menu1.ontouchend = function(e){
e.preventDefault();
if (e.touches && e.touches.length>0) { // iPhone
    x2 = e.touches[0].pageX;
    y2 = e.touches[0].pageY;
} else { // all others
    x2 = e.pageX;
    y2 = e.pageY;
}
}

Anybody know what change in the javascript API for touch events from 2.1 to 2.2?????

You can try:

event.targetTouches[0].pageX

If this does not work, then check if you can get this property from a "touchmove" event. If yes, then store this value (when accessing it in the "touchmove" event) and load it during the "touchend" event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM