Speed Fix: How to Remove the 300ms Delay in jQuery Mobile Apps

后端 未结 4 1181
孤独总比滥情好
孤独总比滥情好 2020-12-13 21:11

How do you remove the click/tap delay from mobile Safari on iOS?

I have fiddled around with event listeners quite a bit, and have used a bunch of different scripts (

4条回答
  •  伪装坚强ぢ
    2020-12-13 22:00

    I am not able to directly post a comment to MikeZ recommendation.

    I used it successfully, but had to do some additional tweek, especially for android devices.

    Instead of calling event.preventDefault(); in gonClick(), I also had to call event.stopImmediatePropagation();

    Otherwise you might run in trouble especially, when dynamic elements, such as panels, are opened on top of the element you clicked.

    Complete gonClick() method to be used with MikeZ solution:

    function gonClick(event) {
        for ( var i = 0; i < coordinates.length; i += 2) {
            var x = coordinates[i];
            var y = coordinates[i + 1];
            if (Math.abs(event.clientX - x) < 25 && Math.abs(event.clientY - y) < 25) {
                event.stopPropagation();
                event.preventDefault();
                event.stopImmediatePropagation();
            }
        }
    };
    

提交回复
热议问题