Jump to content

Touch event doesn't works in IOS7 Iphone


Rnd-
 Share

Recommended Posts

Hi there

Im working for html5 game projects

everything was fine when it works in chrome, safari, firefox, Ipad IO6

but 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

 

Link to comment
Share on other sites

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 IOS7

any one had a trick with this Iphone issue ??

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...