Event touchstart WORKS but touchend not. You can use onmouseup="SOMEfun()"
Even the Samsung Galaxy 3 is a problem with the trigger event.
Add the first event and thay will be working on but
Two scenario :
1)first add onmouseup and than tauchstart or better
2)check mobile or desktop and than add proper events
You can use my detectbrowser function , its very nice (give a name of browser type like mobile_chrome_android_tablet or firefox_desktop , safari_ipad)
Make NOMOBILE global , you can simply replace var NOMOBILE =0; with window["NOMOBILE"]=0;
download browser and device detector :
detect browser and device also class
Class name is DETECTBROWSER()
(on first line in script)
var BROWSER = new DETECTBROWSER()
Check this BROWSER.NAME
This is even crazy't script . Track 10 fingers at same time (in canvas2d)
link : https://github.com/zlatnaspirala/multi-touch-canvas-handler
example for 1)
document.getElementById('myCanvas').addEventListener('touchstart', function(event) {
event.preventDefault();
var touch = event.touches[0];
/* Avatar go left */
if (touch.pageX < 235) {
if (backgroundX < 0){
left = 1;
}
/* Avatar go right */
if (touch.pageX > 470) {
right=1;
}
/* Avatar go lower distance */
if (touch.pageX > 235 && touch.pageX < 470 && touch.pageY >250 ) {
distance--;
}
/* Avatar go to high distance */
if (touch.pageX > 235 && touch.pageX < 470 && touch.pageY <250 ) {
distance++;
}
} ,false);
// solution for touchend
function ENDoff(){
if (moveLEFT==1) { moveLEFT=0; }
if (moveRIGHT==1) { moveRIGHT=0; }
}
HTML CODE
<canvas id="myCanvas" width="480" height="960" onmouseup="touch_UP();"></canvas>