Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

html - html5/android touchcancel

I try to work on an interface on html5 for mobile. i try to follow a mouvement, with touchstart/touchmove/touchend/touchcancel. but when i try to follow a mouvement i allways quikly have au 'touchcancel' and no more touchmove then...

when i try this : http://miniapps.co.uk/code/touchcancel/ it work perfectly, i do not have any problem.

But i think the problem come from the mouvement of the web browser that interfering with my canvas. Do you know can i fix this ?

// I try to explain more : - Here is my test code : http://frys.free.fr/mNaissance/test.html it's the "Jigsaw" puzzle code that i try to make working with a mobile. I had a "log" div hunder the text. And when i do "touchmove" on the grey canvas i have very fast a 'touchcancel' and no anymore 'touchmove' Is it more clear ? sorry for my poor english !

Thanks for help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I believe I found out the reason for this - Android browser (as well as Chrome for Android 4.0+) believes you are trying to scroll, so it fires the touchcancel event. What you should do is

event.preventDefault();

on touchmove event you are capturing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...