代码之家  ›  专栏  ›  技术社区  ›  makat

角度6路由器过渡动画不工作(导航栏)

  •  1
  • makat  · 技术社区  · 8 年前

    不过,它似乎根本不起作用,路由器插座位于导航栏的主要区域: Stackblitz of my app

    请参见“法登.ts“对于动画 请参见“应用导航-组件“html/ts 和应用程序模块

    我希望当点击导航中的链接时,会触发过渡动画。

    1 回复  |  直到 8 年前
        1
  •  3
  •   Sajeetharan    8 年前

    我修改了你的法登.ts一点。

    import {
        trigger,
        animate,
        transition,
        style,
        query, group
      } from '@angular/animations';
    
      export const fadeAnimation = trigger('fadeAnimation', [
        transition('* <=> *', [
    
            /* order */
    
            /* 1 */ query(':enter, :leave', style({ position: 'fixed', width: '100%' })
    
              , { optional: true }),
    
    
            /* 2 */ group([  // block executes in parallel
    
              query(':enter', [
    
                style({ transform: 'translateX(100%)' }),
    
                animate('0.3s ease-in-out', style({ transform: 'translateX(0%)' }))
    
              ], { optional: true }),
    
              query(':leave', [
    
               style({ transform: 'translateX(0%)' }),
    
                animate('0.3s ease-in-out', style({ transform: 'translateX(-100%)' }
              ))], { optional: true }),         
    
            ])
    
          ])
      ]);
    

    WORKING DEMO