Angular4.0动画操作实例详解(2)

import { Component } from '@angular/core'; import {animate, group, query, stagger, state, style, transition, trigger} from "@angular/animations"; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], animations: [ trigger('queryAnimation', [ transition('* => *', [ query('h1', style({ opacity: 0 , color: 'red'})), query('.content', style({ opacity: 0, color: 'green', width: '100px', height: '100px', border: '1px solid red' })), query('h1', animate(1000, style({ opacity: 1, color: ' blue' }))), query('.content', animate(1000, style({ opacity: 1, width: '50px', height: '100px', border: '10px solid green'})), {optional: true}), ]), transition(':leave', [ style({color: 'pink'}), animate(2000) ]) ]), ] }) export class AppComponent { public gg: string; constructor() { } goAnimate() { return true; } }

Angular4.0动画操作实例详解

这个gif有点卡,但是可以大概看出路由切换时是有动画的。这是上面两个例子的效果图

state只能放在trigger里,不能搁在transition里

目前就这么点,才看了一点,以后慢慢补充~~~

更多关于AngularJS相关内容感兴趣的读者可查看本站专题:《AngularJS指令操作技巧总结》、《AngularJS入门与进阶教程》及《AngularJS MVC架构总结

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/299247e96c25dd23d8a5d5ce274cb43a.html