我正在尝试使用以下 HTML 为 ngRepeat div 的子元素错开动画。
<strong>This staggers</strong>
<div ng-repeat="item in items" class="animate-stagger container" ng-animate-children="true">
<div>{{item}}</div>
</div>
<strong>This doesn't stagger</strong>
<div ng-repeat="item in items" class="animate-child-stagger container" ng-animate-children="true">
<div>{{item}}</div>
</div>
我可以使用 CSS 成功地为 ngRepeat div 错开动画:
.animate-stagger{
animation-duration: 2s;
}
.animate-stagger.ng-enter-active {
animation-name: slide;
transform: scaleX(0);
}
.animate-stagger.ng-enter-stagger {
animation-delay: 1s;
animation-duration: 0s;
}
我可以为子 div 设置动画,但它不会使用 CSS 错开:
.animate-child-stagger {
animation-duration: 2s;
}
.animate-child-stagger.ng-enter-active div {
animation: slide 2s;
transform: scaleX(0);
}
.animate-child-stagger.ng-enter-stagger div {
animation-delay: 1s;
animation-duration: 0s;
}
有没有一种方法可以使用 CSS 和 ngAnimate 错开子动画?
最佳答案
我能够通过将动画延迟应用于父元素(即使它是动画的子元素)来完成这项工作。
.animate-stagger-child {
animation-duration: 2s;
}
.animate-stagger-child.ng-enter-active div {
animation: slide 2s;
transform: scaleX(0);
}
.animate-stagger-child.ng-enter-stagger {
animation-delay: 1s;
animation-duration: 0s;
}
关于css - 不能错开 ngAnimate 子动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37373476/