zoukankan      html  css  js  c++  java
  • [Angular2 Animation] Basic animation

    @Component({
      selector: 'app-courses',
      templateUrl: './courses.component.html',
      styleUrls: ['./courses.component.css'],
      animations: [
        trigger('courseHover', [
          state('inactive', style({
            backgroundColor: '#eee',
            transform: 'scale(1)'
          })),
          state('active',   style({
            backgroundColor: '#cfd8dc',
            transform: 'scale(1.1)'
          })),
          transition('inactive => active', animate('300ms ease-in')),
          transition('active => inactive', animate('300ms ease-out'))
        ])
      ]
    })

    Animation start in 'trigger' function. Give a name call 'courseHover'.

    Animation also define 'state', and using 'transition' to animte the state.

    <table>
      <tr *ngFor="let course of (allCourses | async)" [@courseHover]="course.hover" (mouseenter)="course.hover='active'"
          (mouseleave)="course.hover='inactive'">
        <td class="column course-icon">
          <img [src]="course?.iconUrl">
        </td>
        <td class="column course-description">
          {{course.description}}
        </td>
        <td>
          <button [routerLink]="course.url">View</button>
        </td>
      </tr>
    </table>

    So when mouse enter and mouse leave we set 'course.hover' to 'active' or 'inactive'.

    [@courseHover]="course.hover"

    Apply 'courseHover' animation acoording to the 'course.hover'.

    Github

  • 相关阅读:
    python12306抢票
    函数、迭代器、生成器、装饰器
    类(面向对象、增删改查、继承、多态、封装、反射)
    js循环、异常、函数
    js引入、注释、事件
    天融信护网面试
    Java URL处理
    Java多线程编程
    Java网络编程
    Java序列化
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5971924.html
Copyright © 2011-2022 走看看