angularjs排除动画的某些元素 [英] angularjs exclude certain elements from animations

查看:173
本文介绍了angularjs排除动画的某些元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某些地方使用ngAnimate但它接管动画为我所有的NG-类元素。我已经为我不需要ngAnimate接管各种要素大幅编写动画code。他们的加入类似乎真的把事情搞得一团糟。反正排除这些元素?

下面是我试图排除元素:

 < D​​IV纳克级=MyClass的>< / DIV>

ngAnimate添加类像

  $ scope.myclass =搬家< D​​IV CLASS =移动 - 增加NG-CLASS =MyClass的>< / DIV>


解决方案

我在IRC上帮助由jaawerth。他/她指导我此链接:

https://github.com/angular/angular.js/issues/5172

和建议我写这个指令:

  .directive('noAnimate',['$动画,
  功能($动画){
    返回{
      限制:'A',
      链接:功能(范围,元素,ATTRS){
        $ animate.enabled(假,元素)
        范围。$表(函数(){
          $ animate.enabled(假,元素)
        })
      }
    };
  }
])

这解决了这个问题。

I'm using ngAnimate in some places but it's taking over animations for all my ng-class elements. I already had substantial animations code written for various elements that I don't need ngAnimate to take over. Their adding classes really seems to mess things up. Anyway to exclude those elements?

Here's the element I'm trying to exclude:

<div ng-class="myclass"></div>

ngAnimate adds classes like

$scope.myclass = 'move'

<div class="move-add" ng-class="myclass"></div>

解决方案

I was helped by jaawerth on IRC. He/she directed me to this link:

https://github.com/angular/angular.js/issues/5172

and advised me to write this directive:

.directive('noAnimate', ['$animate',
  function($animate) {
    return {
      restrict: 'A',
      link: function(scope, element, attrs) {
        $animate.enabled(false, element)
        scope.$watch(function () {
          $animate.enabled(false, element)
        })
      }
    };
  }
])

Which solved the problem.

这篇关于angularjs排除动画的某些元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆