3

I'm trying to get constant coordinates of where my touch is, unfortunately when I run application I noticed there is a pixel threshold or something that needs to be surpassed before 'touchmove' is activated. Is there a way to change this threshold? Or maybe something else? (Preferably not using JQuery please)

What happens:

Touch = instant X,Y coordinates

Move Touch around = X,Y coordinates don't change until "certain amount of pixels passed" (threshold?)

document.addEventListener('touchstart', onDocumentTouchStart, false);
document.addEventListener('touchmove', onDocumentTouchMove, false);

function onDocumentTouchStart(event)
{
    for(var i = 0; i < event.touches.length; i++)
    {
        clickX[i] = event.touches[i].pageX;
        clickY[i] = event.touches[i].pageY;
    }
}
function onDocumentTouchMove(event)
{
    for(var i = 0; i < event.touches.length; i++)
    {
        clickX[i] = event.touches[i].pageX;
        clickY[i] = event.touches[i].pageY;
    }
}
JimmyBDB
  • 33
  • 5
  • why simply don't you just store the touchstart position and check if your threshold is reached in touchmove? – oiledCode Jan 26 '16 at 10:28
  • I store touchstart into clickX and clickY and console.log the values. It works instantly, only when I start moving it doesn't recognize as touchmove until after a few pixels of movement (I'd say around 10px) I want touchMove to fire as soon as I do any movement, even 1px – JimmyBDB Jan 26 '16 at 10:34
  • Not sure if that will be possible; my guess would be that browsers intentionally apply a minimum threshold distance here, to avoid accidentally triggering actions due normal inaccuracies inherent in this mode of input. – CBroe Jan 26 '16 at 10:42
  • mmmhh ok.. now I get your problem. based on the tag you used in your question I think this is a mobile issue, I guess iOS. So maybe you are experiencing the famous 300ms delay. Now on iOS9 webkit removed this delay but only on unscalable viewports (does your viewport allow zoom?). Anyway if this is the problem a library like fastclick ( https://github.com/ftlabs/fastclick) can help – oiledCode Jan 26 '16 at 10:45
  • Thank you for the responses. @elio.d Yes it is mobile, but I'm currently testing on my android, not iOS. I was really hoping to avoid libraries ): I will try it though – JimmyBDB Jan 26 '16 at 10:50
  • @CBroe Is there any way I can get around it you think? – JimmyBDB Jan 26 '16 at 10:50
  • Oh by the way, just to be clear it is not a time delay, I try moving around in circles a lot, and nothing happens until my movement passes the "10px threshold distance" – JimmyBDB Jan 26 '16 at 10:55
  • -Bump? Still need help on this if possible.. – JimmyBDB Jan 27 '16 at 09:24

0 Answers0