css - 新的列表项应该淡入

标签 css angular list fade

我的 TS 文件中有一个动态呈现给模板的列表:

    <ul*ngFor ="let product of products let ind = index" >
        <li>
            <span> Text will be rendered here</span>                
        </li>
    </ul>

我需要被推送到 MyList 动画的元素。

最佳答案

这是一个关于如何使用动画框架实现的基本示例

动画(如果需要可以转换):

import {
  trigger,
  style,
  transition,
  animate,
} from '@angular/animations';

export const FadeAnimation = trigger(
  'fadeAnimation', [
    transition(':enter', [
      style({
          opacity: 0
        }
      ),
      animate(
        200,
        style({
          opacity: 1
        })
      )
    ]),
    transition(':leave', [
      animate(
        200,
        style({
          opacity: 0
        })
      )
    ])
  ]
);

组件中(导入动画):

@Component({
  selector: 'your-selector',
  templateUrl: './your-component-name.component.html',
  styleUrls: ['./your-component-name.component.css'],
  animations: [
    FadeAnimation,
  ]
})

html 中(如果条件为真:不透明度设置为 1,否则不透明度设置为 0):

<ul*ngFor ="let product of products let i = index" >
    <li [ngClass]="{'highlightClass': i%2==0}" [@fadeAnimation]="true">
        <span> Text will be rendered here</span>
        <span> More text here </span>
    </li>
</ul>

希望对您有所帮助。

关于css - 新的列表项应该淡入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48509000/

相关文章:

JavaScript、图像和 css 不会通过 HTTPS 在 Firefox 中加载

javascript - Angular Material 分页器通过全局背景色隐藏按钮和页数

android - 元素使用权限#android.permission.CAMERA 与在 AndroidManifest.xml 中声明的元素重复

typescript - angular2 形式可观察/事件

java - 根据嵌套数组列表的第一个元素对二维数组列表进行排序

python pandas - 根据包含字符串列表的 B 列更改 A 列中的值

python - 有人可以解释这个表达式 : a[len(a):] = [x] equivalent to list. append(x)

html - Last-Of Type 和 Last-Of-Child

html - 调整 QT 的 QTextEdit 大小以匹配文本宽度

html - 如何在表格单元格中制作响应式图像?