Double Tap Issue iOS

Oh really? That’s good to hear!: Project: https://playcanvas.com/project/688746/overview/double-tap-bug

If you ignore the console logging, all I did was call preventDefault on the touch event:

DetectDoubleTap.prototype.onTouchStart = function(touchEvent) {
    // Only register a tap if one finger is used at one time
    if (touchEvent.touches.length > 1) {
        console.warn('More than one finger');
        return;
    }
    
    console.log('Tap');
    
    // Check if user has previously tapped within the time window to be registered as a double tap
    if (this.timeSinceLastTap < this.doubleTapSpeed) {
        // User has double tapped so let's perform an action
        this.onDoubleTap();

        // We should also set the timeSinceLastTap to be outside the time window so their third tap
        // won't accidently be registered as a double tap
        this.timeSinceLastTap = this.doubleTapSpeed;  
    }
    else {
            // Reset timeSinceLastTap if the click was done after the time allowed for a double
            // tap to register
        console.log('Missed tap: ' + this.timeSinceLastTap);
            this.timeSinceLastTap = 0;
    }
    
    touchEvent.event.preventDefault();
};

I need to do some more investigation on this as this could be solved with a CSS change and I need to make a change to the API/JS docs of the engine to make this fix ‘official’

1 Like