使用 angular 1.2,我包含了 angular-mobile.js 文件并将 ngMobile 模块添加到我的模块依赖项列表中。指令“ng-swipe-left”和“ng-swipe-right”运行良好,但“ng-click”似乎并不快。ipad上好像还有这个300ms的延迟...
使用此功能是否需要更多东西?
顺便问一下,模块 ngTouch 和 ngMobile 有什么区别?滑动指令似乎也适用于其中之一。
谢谢!
似乎这个问题是已知的并且在加载 jQuery 时发生: https ://github.com/angular/angular.js/issues/2548
(根据 'AngularJS 1.2 And Beyond' 的谈话,ngTouch 将成为 NgMobile 的新名称)
看看这个答案,该解决方案也适用于角度 ng-click 指令。
基本上你只需要在 jquery-ui-draggable 的 stop 方法中执行此操作:
$('.selector').draggable({
stop: function(event, ui) {
// event.toElement is the element that was responsible
// for triggering this event. The handle, in case of a draggable.
$( event.toElement ).one('click', function(e){ e.stopImmediatePropagation(); } );
}
});
我正在使用最新的 angular 和 ngtouch 1.2.10,并且还在使用 jQuery。我仍然看到与您相同的问题。我添加了faskclick并修复了它。看起来这个问题在 github 上至少有一个问题开放,所以大概这会在某个时候得到解决。
// This code should be added outside of and angularjs code.
window.addEventListener('load', function () {
FastClick.attach(document.body);
}, false);