2014-04-17 46 views
3

如果我在我的应用程序中加载异步数据。 NgRepeat仅对数组中的第一个元素进行动画处理。只有ngRepeat中的第一个元素是动画

jsFiddle

HTML:

<div ng-repeat="x in data"></div> 

CSS:

.box.ng-enter { 
    -webkit-transition: all 2s ease; 
    transition: all 2s ease; 
    opacity: 0; 
    top: 20px; 
} 

.box.ng-enter-stagger { 
    -webkit-transition-delay: 0.2s; 
    transition-delay: 0.2s; 
} 

.box.ng-enter.ng-enter-active { 
    opacity: 1; 
    top: 0; 
} 

在这个例子中,我使用$超时来模拟一个异步数据源。

这是为什么。

谢谢!

+0

你可以在github上为这个和参考@matsko创建一个问题吗?我试图找到一个不起作用的具体例子。 – matsko

回答

2

我的猜测是这是一个已经修复的错误。自1.2版发布以来,对动画模块进行了大量更改。

Here is a JsFiddle它拥有git的最新源码,用于嵌入动画模块并且问题已消失。如果您需要此功能,那么最好使用最新的源代码加载您自己版本的动画模块。

Here you can compare the 1.2.* branch to the master branch寻找“src/ngAnimate/animate.js”查看模块的所有更改。

Ignore - needed to get the fiddle link to work i get the motivation 
behind requiring code along with a fiddle but in this case it actually makes 
little sense the only modification made to the original was the addition of 
1600 lines of code taken from the latest version of the module. I'm not 
putting that in here. 
+0

来自code.angularjs.org的版本1.3.0-beta.5也适用于我。 – bergdev