Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Losing framerate and / or delay on touchstart, when the cursor doesn't move.

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #246505
    sheepysheep60
    Participant

    I’m trying to respond to a touchstart event on mobile in browser. At the moment I’m using these two listeners:

        document.body.addEventListener('touchstart', function(e) {
          e.preventDefault();
          space_on();
          return false;
        }, false);
    
        document.body.addEventListener('touchend', function(e) {
          e.preventDefault();
          space_off();
          return false;
        }, false);
    

    I’m essentially trying to emulate something I’ve had working really well where I use keydown and keyup events to make a box jump and fall respectively.

    ###The issue I’m having is that a touch start, if you don’t swipe, is actually delaying for a short while. Either that, or a calculation is making me lose framerate.

    I’m already using fastclick and that isn’t effecting this (probably because it was never meant to fire on touchstart listeners). You can see what I mean here:

    https://www.youtube.com/watch?v=8GgjSFgtmFk

    I swipe 3 times and the box jumps immediately, and then I click 3 times and you can see (especially on the second click) it drops frames or is a little bit or is delayed.

    There is a demo here:

    http://codepen.io/EightArmsHQ/live/7d851f0e1d3a274b57221dac9aebc16a/

    Just please bear in mind that you’ll need to either be on a phone, touch device or emulate touches in chrome.

    Can anyone help me lose the framerate drop or delay that is experienced on a touchstart that doesn’t turn into a swipe?

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.