博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Angular动画
阅读量:7201 次
发布时间:2019-06-29

本文共 952 字,大约阅读时间需要 3 分钟。

Angular动画基于W3C的。不在Angular Core中了。

动画其实就是从一个状态过渡到另一个状态。状态本身包含形状,颜色,大小等。

State就是定义状态

Transition是定义如何过渡。

Animate规定了具体怎样过渡,比如时间过渡的速度等。Animate有多个重载形式。

一、例子

通过style把一些css样式应用于实现动画的元素。

在不同的状态下应用不同的状态。

transition负责在不同状态切换时候做怎样的变换。

[@square]是动画的触发器的名字。

import { trigger, state, transition, style, animate } from '@angular/animations';@Component({  selector: "app-root",  templateUrl: "./app.component.html",  styleUrls: ["./app.component.scss"],  animations: [    trigger('square', [      state('green', style({ 'background-color': 'green','height':'100px','transform':'translateX(0)'  })),      state('red', style({ 'background-color': 'red','height':'50px' ,'transform':'translateX(100%)'})),      transition('green=>red', animate('.2s 1s')),      transition('red=>green', animate(1000)),    ])  ]})export class AppComponent {  squareState:string;  onClick(){    this.squareState = this.squareState ==='red'?'green':'red';  }}

 

二、缓动函数

动画执行时候的速度,使其看起来更加真实。

 

转载地址:http://ijdum.baihongyu.com/

你可能感兴趣的文章
多态的理解
查看>>
狗蛋来为您通报时间啦
查看>>
jQuery原理系列-工具函数
查看>>
***常见复杂SQL语句(含统计类SQL)
查看>>
在Mac OS X 10.8中配置Apache + PHP + MySQL
查看>>
linux查看及修改文件权限以及相关
查看>>
代码的抽象三原则
查看>>
lua c函数注册器
查看>>
Entity Framework Code-First(7):Inheritance Strategy
查看>>
Python_tuple部分功能介绍
查看>>
八款优秀Linux浏览器推荐
查看>>
WebApp之Meta标签
查看>>
QT-opencv小结
查看>>
完美兼容IE、Opera、Firefox、360、搜狗的“添加收藏”的最精简代码
查看>>
销毁session
查看>>
【待续】翻译:jQuery Mobile: 他能为你做什么?
查看>>
【装机知识】机箱知识整理
查看>>
网络安全系列 之 协议安全
查看>>
MySQL数据类型和常用字段属性总结
查看>>
换字式密码
查看>>