• @angular/cli项目构建--animations


    使用方法一(文件形式定义):

    animations.ts

    import { animate, AnimationEntryMetadata, state, style, transition, trigger } from '@angular/core';
    
    // Component transition animations
    export const slideInDownAnimation: AnimationEntryMetadata =
      trigger('routeAnimation', [
        state('*',
          style({
            opacity: 1,
            transform: 'translateX(0)'
          })
        ),
        transition(':enter', [
          style({
            opacity: 0,
            transform: 'translateX(-100%)'
          }),
          animate('0.2s ease-in')
        ]),
        transition(':leave', [
          animate('0.5s ease-out', style({
            opacity: 0,
            transform: 'translateY(100%)'
          }))
        ])
      ]);

    在component中使用:

    import { Component, HostBinding } from '@angular/core';
    import { Router }                 from '@angular/router';
    
    import { slideInDownAnimation }   from './animations';
    
    @Component({
      templateUrl: './compose-message.component.html',
      styles: [ ':host { position: relative; bottom: 10%; }' ],
      animations: [ slideInDownAnimation ]
    })
    export class ComposeMessageComponent {
      @HostBinding('@routeAnimation') routeAnimation = true;
      @HostBinding('style.display')   display = 'block';
      @HostBinding('style.position')  position = 'absolute';
    
    }

    使用方法二(直接使用):

    import {
      Component,
      Input
    } from '@angular/core';
    import {
      trigger,
      state,
      style,
      animate,
      transition
    } from '@angular/animations';
     
    import { Hero } from './hero.service';
     
    @Component({
      selector: 'app-hero-list-basic',
      template: `
        <ul>
          <li *ngFor="let hero of heroes"
              [@heroState]="hero.state"
              (click)="hero.toggleState()">
            {{hero.name}}
          </li>
        </ul>
      `,
      styleUrls: ['./hero-list.component.css'],
      animations: [
        trigger('heroState', [
          state('inactive', style({
            backgroundColor: '#eee',
            transform: 'scale(1)'
          })),
          state('active',   style({
            backgroundColor: '#cfd8dc',
            transform: 'scale(1.1)'
          })),
          transition('inactive => active', animate('100ms ease-in')),
          transition('active => inactive', animate('100ms ease-out'))
        ])
      ]
    })
    export class HeroListBasicComponent {
       @Input() heroes: Hero[];
    }
    toggleState() {
        this.state = this.state === 'active' ? 'inactive' : 'active';
      }

    import { animate, AnimationEntryMetadata, state, style, transition, trigger } from '@angular/core';
    // Component transition animationsexport const slideInDownAnimation: AnimationEntryMetadata =  trigger('routeAnimation', [    state('*',      style({        opacity: 1,        transform: 'translateX(0)'      })    ),    transition(':enter', [      style({        opacity: 0,        transform: 'translateX(-100%)'      }),      animate('0.2s ease-in')    ]),    transition(':leave', [      animate('0.5s ease-out', style({        opacity: 0,        transform: 'translateY(100%)'      }))    ])  ]);

  • 相关阅读:
    服务器响应状态码
    细说同域-同父域-跨域
    细说Ajax跨域
    为SQL缓存通知启用数据库
    使用PATINDEX()判断含有[A-Z]、[a-z]、[0-9]之外的字符
    记一次SQLServer的分页优化兼谈谈使用Row_Number()分页存在的问题
    谈谈如何在面试中发掘程序猿的核心竞争力
    “属性”与“特性”区别
    【转】安卓手机无法安装软件的原因总结
    【转】自学android半年,已从.net转型成android程序员
  • 原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/8038424.html
Copyright © 2020-2023  润新知