天天看點

IOS angular ng-click ng-touch 手機延時問題,fastclick

一、ng-click 延時300ms原因:

  手機浏覽器會去判斷,點選是否為double-tap

二、不用ng-touch的原因:

  1.ng-touch 不是angular的核心指令,需要安裝插件

   2.不能移除Textareas, inputs, links, buttons, labels, etc.的延時

  3.他會添加 touchstart, touchmove, touchcancel, touchend, mousedown, mousemove, and mouseup 事件的監聽,增大開支

三、使用Fastclick

if ('addEventListener' in document) {
    document.addEventListener('DOMContentLoaded', function() {
        FastClick.attach(document.body);
    }, false);
}      

四、Android不需要:

Chrome 32+ on Android with width=device-width in the viewport meta tag doesn't have a 300ms delay

<meta name="viewport" content="width=device-width, initial-scale=1">      

五、參考連結:

  http://blog.ionic.io/hybrid-apps-and-the-curse-of-the-300ms-delay/

  https://github.com/ftlabs/fastclick