动画延迟ng-repeat [英] Animation delay ng-repeat

查看:203
本文介绍了动画延迟ng-repeat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ng-repeat并在CSS中延迟的这段代码:

I have this code with ng-repeat and delay in css:

<div class="card moveUp" ng-repeat="x in optionsCards" style="animation: moveUp 0.50s ease forwards;">

    <span class="fec">Updated Aug 29, 2016</span>

    <span class="title">Internet Banner Advertising…</span>

</div>

我需要增加ng-repeat的每一项中的延迟值。例如:

I need that the delay value in every item of ng-repeat , increase. For example:

第一项:动画:moveUp 0.50s缓行
第二项:动画:moveUp 0.60s缓行
第三项:动画:moveUp 0.70s轻松前进

First item: animation: moveUp 0.50s ease forwards Second item: animation: moveUp 0.60s ease forwards Third item: animation: moveUp 0.70s ease forwards

我如何做到这一点?

谢谢

推荐答案

您可以将 0.50s 替换为样式具有角表达式的属性。一个简单的解决方案是:

You can substitute 0.50s in style attribute with angular expression. A simple solution would be:

<div class="card moveUp" ng-repeat="x in optionsCards" style="animation: moveUp {{ (0.5 + 0.1 * $index) + 's' }} ease forwards;">

$ index 包含当前 ng-repeat 元素,因此,如果将其乘以 0.1 并添加到基数 0.5 ,每件商品的延迟时间都比前一件商品长0.1秒。

$index contains an index of current ng-repeat element so if you multiply it by 0.1 and add to base 0.5, each item will have delay 0.1s longer than its predecessor.

这篇关于动画延迟ng-repeat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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