관리 메뉴

千日夢의 Tistory

[Hybrid/Ionic]Windows Platform일 ng-click 이벤트 관련 더블클릭 방지 본문

Language/Mobile

[Hybrid/Ionic]Windows Platform일 ng-click 이벤트 관련 더블클릭 방지

千日夢 천일몽 2016.11.04 11:41
출처 : https://github.com/driftyco/ionic/issues/2885



window.addEventListener('click', function(event) {
  if (Object.prototype.toString.call(event) == '[object PointerEvent]') {
    event.stopPropagation();
  }
}
, true);


또는


ionic.Platform.isIE = function () {
    return ionic.Platform.ua.toLowerCase().indexOf('trident') > -1;
}

if (ionic.Platform.isIE()) {
    angular.module('ionic')
      .factory('$ionicNgClick', ['$parse', '$timeout', function ($parse, $timeout) {
          return function (scope, element, clickExpr) {
              var clickHandler = angular.isFunction(clickExpr) ? clickExpr : $parse(clickExpr);

              element.on('click', function (event) {
                  scope.$apply(function () {
                      if (scope.clicktimer) return; // Second call
                      clickHandler(scope, { $event: (event) });
                      scope.clicktimer = $timeout(function () { delete scope.clicktimer; }, 1, false);
                  });
              });

              // Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click
              // something else nearby.
              element.onclick = function (event) { };
          };
      }]);
}


0 Comments
댓글쓰기 폼