第一次尝试使用角度动画,无法弄清楚我做错了什么。
我将AngularJS v1.3.0-build.2805用于Angular本身和动画模块。
-1。包含模块
angular.module('profileApp', [
'ngAnimate'
]);
-2。在css中定义样式
.fade-in{
transition: 1s linear all;
-webkit-transition: 1s linear all;
}
.fade-in.ng-enter,
.fade-in.ng-leave.ng-leave-active{
opacity: 0;
}
.fade-in.ng-enter.ng-enter-active,
.fade-in.ng-leave{
opacity: 1;
}
-3。包括ng-repeat中的类
<a class="item fade-in" ng-repeat="item in collection" href="{{client.getPath('product/'+item.slug)}}">
<div class="thumb">
<img ng-src="{{item.images[0].imagename}}" alt="{{item.style_name}}">
</div>
<h3>{{item.style_name}}</h3>
</a>
我在这里缺少什么?
答案 0 :(得分:4)
这是一个伟大的tutorial关于angularjs中令人震惊的动画,由yearofmoo
如您对问题的评论中所述,通过pixelbits:
如果要在加载时错开动画,则必须将项目推送到数组中,而不是将整个数组分配到范围。
他还提供了一个很好的plunkr,展示了如何正确制作动画。
list.html
<div id="list-wrap">
<ul id="page-list">
<li class="page-list-item" ng-repeat="item in items" ng-click="tapHandle(this)">
<span class="page-list-text">{{ item }}</span>
</li>
</ul>
</div>
的style.css:
.page-list-item.ng-enter-stagger,
.page-list-item.ng-leave-stagger {
-webkit-transition-delay: 0.2s;
-moz-transition-delay: 0.2s;
-ms-transition-delay: 0.2s;
-o-transition-delay: 0.2s;
transition-delay: 0.2s;
-webkit-transition-duration: 0;
-moz-transition-duration: 0;
-ms-transition-duration: 0;
-o-transition-duration: 0;
transition-duration: 0;
}
.page-list-item.ng-enter {
-webkit-transition: 0.2s linear all;
-moz-transition: 0.2s linear all;
-ms-transition: 0.2s linear all;
-o-transition: 0.2s linear all;
transition: 0.2s linear all;
-ms-opacity: 0;
opacity: 0;
}
.page-list-item.ng-enter.ng-enter-active {
-ms-opacity: 1;
opacity: 1;
}
.page-list-item.ng-leave {
-webkit-transition: 0.2s linear all;
-moz-transition: 0.2s linear all;
-ms-transition: 0.2s linear all;
-o-transition: 0.2s linear all;
transition: 0.2s linear all;
-ms-opacity: 1;
opacity: 1;
}
.page-list-item.ng-leave.ng-leave-active {
-ms-opacity: 0;
opacity: 0;
}