Saturday, 15 May 2010

javascript - touch event not working on android -



javascript - touch event not working on android -

i built spotlight style overlay works fine on iphones/tablets/and pc it's not working on android devices. here's i'm working with:

<script type="text/javascript"> var spot = document.getelementbyid('spot'); var width = document.documentelement.clientwidth; var height = document.documentelement.clientheight; /* bit of js respond mouse events */ function movespot(e){ var x = 0; var y = 0; if (!e) var e = window.event; if (e.pagex || e.pagey) { x = e.pagex; y = e.pagey; } else if (e.clientx || e.clienty) { x = e.clientx + document.body.scrollleft; y = e.clienty + document.body.scrolltop; } var style = '-webkit-gradient(radial, '+x+' '+y+', 0, '+x+' '+y+', 100, from(rgba(0,0,0,0)), to(rgba(0,0,0,1)), color-stop(0.8, rgba(0,0,0,0)))'; spot.style.backgroundimage = style; } window.onload = function() { //window.onmousemove = movespot; window.ontouchmove = movespot; } </script>

some direction issue appreciated.

i figured out. need alter e.pagex , e.pagey event.touches[0].pagex , event.touches[0].pagey within code phone call event.preventdefault(); seemed resolve issue.

javascript android

No comments:

Post a Comment