AngularJS: ngTouch 300ms Delay

前端 未结 3 1132
有刺的猬
有刺的猬 2020-12-23 00:03

This Plunkr has 2 links. The one on the left side is using the ng-click directive with the on angular-touch module inserted. As said in the angular touch module description

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 00:51

    Because angulars ngTouch module is only removing the 300ms delay on ng-click directives, i'm using fastclick.js now which harmonates perfectly fine with angular.

    At the beginning it did not work for me, because I attached the Fastclick library before its script was loaded, before the DOM was ready. I fixed this by wrapping the function in the run block of my angular app. This function executes code after the DOM is ready.

    angular.module('myModule', []).
      run(function() {
        FastClick.attach(document.body);
      });
    

    This way is suggested by the latest screencast on the angularjs youtube channel.

提交回复
热议问题