Rnd- Posted November 19, 2013 Share Posted November 19, 2013 Hi thereIm working for html5 game projectseverything was fine when it works in chrome, safari, firefox, Ipad IO6but when Im trying in IOS7 Iphone every touch event was not works.even the 'e.preventdefault' was not firing, its keep zoom in when double touch. does anyone had some tricks for ios7 ?? thx before Quote Link to comment Share on other sites More sharing options...
rich Posted November 19, 2013 Share Posted November 19, 2013 You're going to need to show us some code or something, as it's obvious from the hundreds of games people show here that touch events work just fine on iOS7, so it has to be something specific to the way you're doing it I'm afraid. Quote Link to comment Share on other sites More sharing options...
Rnd- Posted November 23, 2013 Author Share Posted November 23, 2013 oh sorry Admin.. my bad...Im Make some new page with my code, save it as test.html<head><body> <canvas id="canvastest" width="800" height="600"></canvas> <script> var ua = navigator.userAgent.toLowerCase(); var checks = Boolean(ua.match(/android/))|| Boolean(ua.match(/ipod/))|| Boolean(ua.match(/ipad/))|| Boolean(ua.match(/tablet/))|| Boolean(ua.match(/tablet pc/)) var touchable = checks && (typeof (document.ontouchstart) != 'undefined'); var canvas; var spanTest; document.addEventListener('DOMContentLoaded',domloaded,false); function domloaded() { canvas = document.getElementById("canvastest"); spanTest = document.getElementById("spanTest"); ctx = canvas.getContext("2d"); ctx.fillStyle= "#000000"; ctx.fillRect(0, 0, 800, 600); if(touchable){ canvas.addEventListener('touchstart',mouseDown,false); canvas.addEventListener('touchmove',mouseMove,false); //document.addEventListener('touchend',mouseUp,false); }else{ canvas.addEventListener('mousedown',mouseDown,false); canvas.addEventListener('mousemove',mouseMove,false); //document.addEventListener('mouseup',mouseUp,false); } } function getMousePos(evt) { if(touchable && evt.touches.length>1)return; if(touchable)evt = evt.changedTouches[0]; var rect = canvas.getBoundingClientRect(); return { x: (evt.clientX - rect.left), y: (evt.clientY - rect.top) }; } function mouseDown(e) { var mousePos = getMousePos(e); //alert(mousePos); spanTest.innerHTML = mousePos.x + "-" + mousePos.y; e.preventDefault(); } function mouseMove(e) { var mousePos = getMousePos(e); spanTest.innerHTML = mousePos.x + "-" + mousePos.y; e.preventDefault(); } </script> <span id="spanTest">test</span> </body></head>Im testing it in Iphone 4 IOS7, position when touchstart works well,but it seems preventdefault dont works, when I drag (touchmove) the page was keep scrolling.but its works well in Ipad IOS6, Ipad Mini IOS7. it seems problem is with Iphone not with the IOS7any one had a trick with this Iphone issue ?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.