最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

angular2系列之路由轉(zhuǎn)場(chǎng)動(dòng)畫的示例代碼

 更新時(shí)間:2017年11月09日 11:49:59   作者:steryn  
本篇文章主要介紹了angular2系列之路由轉(zhuǎn)場(chǎng)動(dòng)畫的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

Angular2的動(dòng)畫系統(tǒng)賦予了制作各種動(dòng)畫效果的能力,致力于構(gòu)建出與原生CSS動(dòng)畫性能相同的動(dòng)畫。

Angular2的動(dòng)畫主要是和@Component結(jié)合在了一起。

animations元數(shù)據(jù)屬性在定義@Component裝飾。就像template元數(shù)據(jù)屬性!這樣就可以讓動(dòng)畫邏輯與其應(yīng)用代碼緊緊集成在一起,這讓動(dòng)畫可以更容易的出發(fā)與控制。

一.在app.mudule.ts中引入:

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

并在@NgModule中的imports添加:

imports: [BrowserAnimationsModule],

二.創(chuàng)建文件定義名為animations.ts用來書寫轉(zhuǎn)場(chǎng)動(dòng)畫

import { animate, AnimationEntryMetadata, state, style, transition, trigger } from'@angular/core';
// Component transition animations
export const slideInDownAnimation: AnimationEntryMetadata =
// 動(dòng)畫觸發(fā)器名稱
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%)'
    }))
  ])
]);

三.在需要添加轉(zhuǎn)場(chǎng)動(dòng)畫的頁面操作

引入import {HostBinding } from '@angular/core';(如果引入過直接將HostBinding添加進(jìn)去就好,不要重復(fù)引入,多嘴了...)

再引入你寫好的動(dòng)畫模板:import { slideInDownAnimation } from '../animation';

在@Component中添加:animations:[slideInDownAnimation],

最后:

  // 添加@HostBinding屬性添加到類中以設(shè)置這個(gè)路由組件元素的動(dòng)畫和樣式
  @HostBinding('@routeAnimation') routeAnimation = true;
  @HostBinding('style.display') display = 'block';
  @HostBinding('style.position') position = 'absolute';

四.至此你可以去瀏覽器看看效果了,如果沒有錯(cuò)誤

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

保德县| 公主岭市| 海门市| 玛沁县| 莆田市| 蓝田县| 建湖县| 大英县| 宣化县| 中牟县| 林芝县| 广灵县| 保亭| 和顺县| 五家渠市| 调兵山市| 东丽区| 广南县| 蕉岭县| 洱源县| 南皮县| 剑川县| 酒泉市| 雷波县| 平阴县| 黎城县| 彝良县| 元谋县| 方山县| 独山县| 桂东县| 梧州市| 瑞昌市| 德钦县| 保定市| 阿克陶县| 潍坊市| 富平县| 五台县| 福安市| 延川县|