大佬教程收集整理的这篇文章主要介绍了angularjs – 停止角动画从ng-show/ng-hide发生,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<i class="fa fa-spin fa-spinner" ng-show="loading"></i>
我也使用AngularToaster的通知消息依赖于ngAnimate。当我在我的AngularJS应用程序中包含ngAnimate时,它通过以奇怪的方式动画化它们来混乱我的加载旋转。我想阻止这种情况发生,但没有找到一个方法来禁用只是这些装载器的动画(它也会臭了,必须更新我的应用程序中的每个加载器)。
显示我的确切问题。
$animateProvider.classNameFilter(/^((?!(fa-spinner)).)*$/); //$animateProvider.classNameFilter(/^((?!(fa-spinner|class2|class3)).)*$/);
演示:
http://plnkr.co/edit/lbqviQ87MQoZWeXplax1?p=preview
Angular docs状态:
作为使用No-animate指令的注释的另一个答案,您可以编写一个将以更高优先级运行并禁用动画的ng-show伪指令。我们将只做这个如果元素有fa-spinner类。
problemApp.directive('ngShow',function($compile,$animatE) { return { priority: 1000,link: function(scope,element,attrs) { if (element.hasClass('fa-spinner')) { // we Could add no-animate and $compile per // http://stackoverflow.com/questions/23879654/angularjs-exclude-certain-elements-from-animations?rq=1 // or we can just include that no-animate directive's code here $animate.enabled(false,element) scope.$watch(function() { $animate.enabled(false,element) }) } } } });
演示:http://plnkr.co/edit/BYrhEompZAF5RKxU7ifJ?p=preview
最后,和上面类似,如果我们想使它更加模块化,我们可以使用No-animate指令。在这种情况下,我命名的指令faSpin,你可以在上面的答案。这本质上是相同的,只有我们保留的指令从上述代码集的评论中提到的SO答案。如果你只关心fa-spin动画问题命名它这样工作很好,但如果你有其他ng-show动画问题,你想要命名为ngShow并添加到if子句。
problemApp.directive('noAnimate',['$animate',function($animatE) { return { reStrict: 'A',attrs) { $animate.enabled(false,element) }) } }; } ]) problemApp.directive('faSpin',attrs) { if (element.hasClass('fa-spinner')) { element.attr('no-animate',truE); $compile(element)(scopE); } } } });
以上是大佬教程为你收集整理的angularjs – 停止角动画从ng-show/ng-hide发生全部内容,希望文章能够帮你解决angularjs – 停止角动画从ng-show/ng-hide发生所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。