zoukankan      html  css  js  c++  java
  • Angular动画

    animation

    // 使用方法
    git clone https://git.oschina.net/mumu-osc/learn-component.git
    cd learn-component
    git pull origin animation
    npm install 
    ng serve
    

    写法

    // fly-in.ts
    import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';
    
    export const flyIn = trigger('flyIn', [
        transition('void => *', [
            animate(3000, keyframes([
                style({ opacity: 0, transform: 'translateX(-100%)', offset: 0 }),
                style({ opacity: 1, transform: 'translateX(25px)', offset: 0.3 }),
                style({ opacity: 1, transform: 'translateX(0)', offset: 1.0 })
            ]))
        ]),
        transition('* => void', [
            animate(300, keyframes([
                style({ opacity: 1, transform: 'translateX(0)', offset: 0 }),
                style({ opacity: 1, transform: 'translateX(-25px)', offset: 0.7 }),
                style({ opacity: 0, transform: 'translateX(100%)', offset: 1.0 })
            ]))
        ])
    ]);
    

    使用

    <div class="panel panel-primary" [@flyIn]="state">
      <div class="panel-heading">飞入效果</div>
      <div class="panel-body">
        飞入效果
      </div>
    </div>
    
    import { Component, OnInit } from '@angular/core';
    import { flyIn } from '../animations/fly-in';
    
    @Component({
      selector: 'app-test-fly-in',
      templateUrl: './test-fly-in.component.html',
      styleUrls: ['./test-fly-in.component.css'],
      animations:[flyIn]
    })
    export class TestFlyInComponent implements OnInit {
      state:string;
    
      constructor() { }
    
      ngOnInit() {
      }
    
    }
    

    注意

    需要在主模块中引入BrowserAnimationsModule

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    
    import { AppComponent } from './app.component';
    import { TestFlyInComponent } from './test-fly-in/test-fly-in.component';
    
    @NgModule({
      declarations: [
        AppComponent,
        TestFlyInComponent
      ],
      imports: [
        BrowserModule,
        BrowserAnimationsModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    
  • 相关阅读:
    springboot 整合 mybatis plus
    Centos7下安装Docker
    idea 将项目打包成 docker 镜像 推送到 阿里云
    Windows10 使用 docker toolbo x安装 docker
    js 修改 url 但不刷新页面
    MySQL-建数据库的字符集与排序规则说明
    7.Redis 缓存过期处理与内存淘汰机制
    6.Redis 主从复制原理总结
    5.Redis 持久化
    4.Springboot整合Redis
  • 原文地址:https://www.cnblogs.com/zheng-chuang/p/7418589.html
Copyright © 2011-2022 走看看