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