Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Standalone App 300ms Click Delay

Last year webkit removed the 350ms delay for iOS. When I run my website in Safari's mobile browser, the delay no longer exists, and works as expected.

However, when I run my web application in standalone mode, the delay exists, and is blatantly obvious.

Here's my metatag that I'm using:

<meta name="viewport" content="initial-scale=1.0, user-scalable=no, maximum-scale=1, width=device-width">

I've tried variations of the sort, without luck.

It's hard to find anything about standalone applications, none-the-less this apparent issue.

Does anyone know why this 350ms delay click only occurs in standalone mode? As a workaround, I'm having to bring fastclick into the project, which isn't ideal.

Note: I'm running iOS 9.3.5 / iPhone 6

like image 321
contactmatt Avatar asked Oct 10 '16 05:10

contactmatt


People also ask

Is 300ms slow?

Studies have shown that 100ms is the maximum delay for an interface to feel instantaneous to the user. Despite this, the mobile web is plagued by a sweeping feedback problem: a 300ms delay after you touch anything.

What is 300ms delay?

On touch devices, a click event has a 300ms delay before firing. The reason for this the delay is that browsers need that buffer to make sure you aren't going to double-tap on anything. The result is that if you use click events blindly, that delay creates a noticeable lag as users interact with elements on your page.


1 Answers

There seems to be no native workaround, and this appears to be a known issue, regardless of being fixed in webkit.

Begin Rant

Apples lack of support, and attention to detail for standalone apps is truly unbelievable; especially as of version 9.3.5.

Between this issue, and the major Youtube player issue on standalone apps. Perhaps Apple should stop worrying about removing the headphone jack, and adding some mystical "Touch Bar, and actually fix their damn platform.

End Rant

You'll have to use FastClick to solve the issue. Apply it only to iOS. You can go further, and only apply it to standalone apps, as it works fine if the app isn't in standalone.

My script tag is placed after the DOM, and the initialization looks like this:

    if (isIos() && isRunningStandalone()) {
        // Initialize Fast Click
        // Even with the latest webkit updates, unfortunatley iOS standalone apps still have the 350ms click delay,
        // so we need to bring in fastclick to alleviate this.
        // See https://stackoverflow.com/questions/39951945/ios-standalone-app-300ms-click-delay
        if ('addEventListener' in document) {
            document.addEventListener('DOMContentLoaded', function () {
                FastClick.attach(document.body);
            }, false);
        }
    }

   isIos = function () {
        // Reference: https://stackoverflow.com/questions/9038625/detect-if-device-is-ios#answer-9039885
        return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
    };

   isRunningStandalone = function () {
        // Bullet proof way to check if iOS standalone
        var isRunningiOSStandalone = window.navigator.standalone;

        // Reliable way (in newer browsers) to check if Android standalone.
        // https://stackoverflow.com/questions/21125337/how-to-detect-if-web-app-running-standalone-on-chrome-mobile#answer-34516083
        var isRunningAndroidStandalone = window.matchMedia('(display-mode: standalone)').matches;

        return isRunningiOSStandalone || isRunningAndroidStandalone;
    };
like image 128
contactmatt Avatar answered Oct 29 '22 01:10

contactmatt