How to add my content one by one with angular animation - Stack Overflow

For a presentation page I want to display the content of my page element by element with Angular animat

For a presentation page I want to display the content of my page element by element with Angular animations

My goal was to make an animation that hides my content and make an animation for each element but my content is well hidden (:self) but the other animations have no effect until the end of the animation where all my content appears at once

animations : [ 
    trigger('homeAnimations', [
      transition(':enter', [
        query(':self',[
          style({opacity:0})
        ]),
        query('#presentation h1', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#presentation h2', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#presentation p', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn1', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn2', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn3', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
      ])
    ])
  ],

For a presentation page I want to display the content of my page element by element with Angular animations

My goal was to make an animation that hides my content and make an animation for each element but my content is well hidden (:self) but the other animations have no effect until the end of the animation where all my content appears at once

animations : [ 
    trigger('homeAnimations', [
      transition(':enter', [
        query(':self',[
          style({opacity:0})
        ]),
        query('#presentation h1', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#presentation h2', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#presentation p', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn1', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn2', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn3', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
      ])
    ])
  ],
Share Improve this question asked Mar 4 at 12:47 KoZ x TrickyKoZ x Tricky 133 bronze badges 1
  • please share the minimal reproducible code, working stackblitz (If possible), steps to replicate the issue and expected output. – Naren Murali Commented Mar 4 at 12:49
Add a comment  | 

1 Answer 1

Reset to default 0

If your elements are the children of the :self, the child will not be displayed without the parent being visible.

Solution: first hide the children:

animations : [ 
    trigger('homeAnimations', [
      transition(':enter', [
        // hide elements that you do not want to display:
        query('#presentation h1', [
          style({opacity:0})
        ], { optional: true }),
        query('#presentation h2', [
          style({opacity:0})
        ], { optional: true }),
        query('#presentation p', [
          style({opacity:0})
        ], { optional: true }),
        query('#btn1', [
          style({opacity:0})
        ], { optional: true }),
        query('#btn2', [
          style({opacity:0})
        ], { optional: true }),
        query('#btn3', [
          style({opacity:0})
        ], { optional: true }),

        // show them using transition animation:
        query('#presentation h1', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#presentation h2', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#presentation p', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn1', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn2', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
        query('#btn3', [
          animate('2s', style({ opacity: 1 }))
        ], { optional: true }),
      ])
    ])
  ],

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745042524a4607897.html

相关推荐

  • How to add my content one by one with angular animation - Stack Overflow

    For a presentation page I want to display the content of my page element by element with Angular animat

    8小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信