[Angular] FadeIn and FadeOut animation in Angular
To define an Angular Animation, we using DSL type of language. Means we are going to define few animations ('fadeIn', 'fadeOut').
Then we need to define something called 'transition', which use those animations. 'transition' defines from which state to which state, we should apply animation.
Last we need trigger to pick off the animation.
A little bit more coding needed and might not be easy to get the idea at once.
Remeber this
Trigger transitions to use animations to animate style
Read from 'Right' to 'Left', what we need is
- animation
- transitions
- trigger
1. Animations:
import {animation, style, animate, trigger, transition, useAnimation} from '@angular/animations';
/*
* DSL
* */
export const fadeIn = animation([
// start
style({
opacity: ,
'border-radius': '5px'
}),
// end
animate(
'1000ms',
style({
opacity: ,
})
)
]);
export const fadeOut = animation(
animate(
'500ms',
style({opacity: })
)
);
2. Transition:
/*
* Transition
* */
export const fadeInOut = trigger('fadeInOut', [
transition('void => *', useAnimation(fadeIn)),
transition('* => void', useAnimation(fadeOut))
]);
From 'void' means 'nothing..', the ui element might not in the DOM yet.
To '*' any state, we use fadeIn animation.
From 'any state' to 'void', we use fadeOut animation.
And we also define 'fadeInOut' trigger to use in HTML:
<au-modal [@fadeInOut] *auModalOpenOnClick="paymentModal" [body]="modalBody"> </au-modal>
To see it works, we need to add animations in component:
import { Component } from '@angular/core';
import {fadeInOut} from './animations';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
animations: [fadeInOut]
})
export class AppComponent {
title = 'app';
}
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';
import {AppComponent} from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
....
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
[Angular] FadeIn and FadeOut animation in Angular的更多相关文章
- Jquery小例子:全选按钮、加事件、挂事件;parent()语法;slideToggle()语法;animate()语法;元素的淡入淡出效果:fadeIn() 、fadeOut()、fadeToggle() 、fadeTo();function(e):e包括事件源和时间数据;append() 方法
function(e): 事件包括事件源和事件数据,事件源是指是谁触发的这个事件,谁就是事件源(div,按钮,span都可以是事件源),时间数据是指比如点击鼠标的事件中,事件数据就是指点击鼠标的左建或 ...
- [Angular 2 Router] Configure Your First Angular 2 Route
Using the Angular 2 router requires defining routes, passing them in to the RouterModule.forRoot and ...
- 【Angular专题】——(1)Angular,孤傲的变革者
目录 一. 漫谈Angular 二. 如果你还在使用Angularjs 三. 我计划这样学习Angular技术栈 一. 漫谈Angular Angular,来自Google的前端SPA框架,与Reac ...
- jQuery效果-----fadeIn()、fadeOut()、fadeToggle()、fadeTo()
fadeIn(),fadeOut(),fadeToggle(),fadeTo() fadeIn()-----淡入已经隐藏的元素(把隐藏的被选元素渐渐显示出来). 语法:$(selector).fade ...
- [Angular] Use Angular components in AngularJS applications with Angular Elements
When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular El ...
- 利用jquery的淡入淡出函数(fadeIn和fadeOut)--实现轮播
首先说下,我在网上找的例子全是用的UL 实现,其实大可不必,只要是能包含img标签的HTML标签都可以做轮播效果.利用jquery的淡入淡出函数(fadeIn和fadeOut).废话也不多说,边上代码 ...
- Angular 从入坑到挖坑 - Angular 使用入门
一.Overview angular 入坑记录的笔记第一篇,完成开发环境的搭建,以及如何通过 angular cli 来创建第一个 angular 应用.入坑一个多星期,通过学习官方文档以及手摸手的按 ...
- [从 0 开始的 Angular 生活]No.38 实现一个 Angular Router 切换组件页面(一)
前言 今天是进入公司的第三天,为了能尽快投入项目与成为团队可用的战力,我正在努力啃官方文档学习 Angular 的知识,所以这一篇文章主要是记录我如何阅读官方文档后,实现这个非常基本的.带导航的网页应 ...
- Angular项目构建指南 - 不再为angular构建而犹豫不决(转)
如果你不知道什么是Angular或者根本没听说过,那么我接下来所说的对你来说毫无益处,不过如果你打算以后会接触Angular或者干脆要涨涨姿势~读下去还是有点用的. Angular和它之前所出现的其余 ...
随机推荐
- Unity3D:粒子系统Particle System
1. GameObject → Create Other → Particle System. 2. 选中 Particle System,可看到下列屬性: 3.Particle System: ...
- MySql 存储引擎的选取
存储引擎是为不同的表类型处理 SQL 操作的 MySql 组件.InnoDB 是默认的.最通用的存储引擎,也是官方推荐使用的存储引擎,除非一些特定案例.MySql 5.6 中的 CREATE TABL ...
- html5中的容器标签和文本标签
html5中的容器标签和文本标签 html中的容器级标签和文本级标签,css中的块级元素和行内元素是我们常常拿来比较的四个名词(行内块级暂时先不考虑). 容器标签 容器级的标签可以简单的理解为能嵌套其 ...
- vue -- 跨域cookie 丢失的问题
前端使用了vue-reource的$http进行请求后台接口 登陆完成后,服务端监控发现无法拿到cookie,下面看几张前端控制台监控的图 reqqust Header 没有显示cookie 信息 ...
- 关于li的排列,我的面试题
来到北京的第二周,收到了单位的面试,一面的时候面试官问了微信钱包里的那个快速入口的排列,我当时在面试官的引导下答的还可以,但是在实际中有很多的方法和各自不同的问题,我来总结下. 1.flex布局,其实 ...
- Checkpoint & cache & persist
checkpoint checkpoint(检查点)是Spark为了避免长链路,大计算量的Rdd不可用时,需要长时间恢复而引入的.主要就是将通过大量计算而获得的这类Rdd的数据直接持久化到外部可靠的存 ...
- poweroff---关闭计算机操作系统并且切断系统电源。
poweroff命令用来关闭计算机操作系统并且切断系统电源. 语法 poweroff(选项) 选项 -n:关闭操作系统时不执行sync操作: -w:不真正关闭操作系统,仅在日志文件“/var/log/ ...
- 【CS Round #39 (Div. 2 only) D】Seven-segment Display
[Link]:https://csacademy.com/contest/round-39/task/seven-segment-display/ [Description] 0..9各自有一个数字, ...
- [NOI.AC#35]string 缩点+拓扑排序
链接 因为有交换相邻字母,因此给你字符串就相当于给你了这个字符串的所有排列 把等价的串映射到整数范围,再根据 \(m\) 种魔法连边,缩点后在 DAG 上DP即可 无耻地用了int128 #inclu ...
- 引用 Windows Server 2003 FTP服务器配置详解
引用 昆神之星 的 Windows Server 2003 FTP服务器配置详解 1.FTP文件传输协议,主要用于计算机之间文件传输,是互联网上仅次于www的第二大服务.本文主要演示如何在Window ...