@Component({
selector: 'app-courses',
templateUrl: './courses.component.html',
styleUrls: ['./courses.component.css'],
animations: [
trigger('courseHover', [
state('inactive', style({
backgroundColor: '#eee',
transform: 'scale(1)'
})),
state('active', style({
backgroundColor: '#cfd8dc',
transform: 'scale(1.1)'
})),
transition('inactive => active', animate('300ms ease-in')),
transition('active => inactive', animate('300ms ease-out'))
])
]
})

Animation start in 'trigger' function. Give a name call 'courseHover'.

Animation also define 'state', and using 'transition' to animte the state.

<table>
<tr *ngFor="let course of (allCourses | async)" [@courseHover]="course.hover" (mouseenter)="course.hover='active'"
(mouseleave)="course.hover='inactive'">
<td class="column course-icon">
<img [src]="course?.iconUrl">
</td>
<td class="column course-description">
{{course.description}}
</td>
<td>
<button [routerLink]="course.url">View</button>
</td>
</tr>
</table>

So when mouse enter and mouse leave we set 'course.hover' to 'active' or 'inactive'.

[@courseHover]="course.hover"

Apply 'courseHover' animation acoording to the 'course.hover'.

Github

最新文章

  1. 浏览器渲染引擎,提高css渲染速度。
  2. SharePoint 2007 User Re-created in AD with new SID issue on MySite
  3. Java web项目在linux环境下自动编译和部署脚本
  4. 【Todo】【转载】Spark学习 &amp; 机器学习(实战部分)-监督学习、分类与回归
  5. html5中的表单
  6. android学习日记03--常用控件ListView
  7. SGU 193.Chinese Girls&#39; Amusement
  8. html中把li前面的的小圆点换成小图片的方法
  9. 3 分钟的高速体验 Apache Spark SQL
  10. linux环境下搭建 j2ee环境
  11. 51Nod 1016 水仙花数 V2(组合数学,枚举打表法)
  12. 【Unity3D技术文档翻译】第1.5篇 本地使用 AssetBundles
  13. bzoj 3166 [Heoi2013]Alo 可持久化Trie
  14. Vue源码解析---数据的双向绑定
  15. Python全栈学习_day002作业
  16. POJ.1743.Musical Theme(后缀数组 倍增 二分 / 后缀自动机)
  17. 使用openstackclient调用Keystone v3 API
  18. flash存储原理
  19. MyEclipse2017CI破解教程
  20. Apache Hadoop 简介

热门文章

  1. 82.QT实现委托构造
  2. web api 特点
  3. Kinect 开发 —— 面部识别
  4. python3 requests 模块 json参数和data参数区别
  5. POJ 1426 Find The Multiple (DFS / BFS)
  6. 用openssl生成含有中文信息的证书
  7. 类似C语言格式化输出
  8. vue使用marked.js实现markdown转html并提取标题生成目录
  9. python学习三:列表,元组
  10. 使用PyCharm安装第三方库