Angular 2 start list animations

I am trying to stagger the animation in my application with a dynamic list. I would like the animation to come in and go, if possible, but decide to just get the work to work.

animations: [
    trigger('slideIn', [
        transition(':enter', [
            style({
                transform: 'translate3d(0,-10px,0)',
                opacity: 0
            }),
            animate('0.1s', style({
                transform: 'translate3d(0,0,0)',
                opacity: 1
            }))
        ])
    ])  
  ]

Above is the animation code that I cannot run, and below is how I implemented it in the template.

<ion-content [@listAnimation]="eventsList?.length">
    <ion-list>
              <event-item *ngFor="let item of eventsList" [item]="item"></event-item>
    </ion-list>
     <empty-list [list]="eventsList" [message]="'There are no event items to display.'"></empty-list>
    <ion-infinite-scroll [enabled]="infiniteScroll === null" (ionInfinite)="doInfinite($event)">
        <ion-infinite-scroll-content></ion-infinite-scroll-content>
     </ion-infinite-scroll>
</ion-content>

Please let me know where I made a mistake.

+4
source share
2 answers

I haven't done the animation yet, but according to: https://www.yearofmoo.com/2017/06/new-wave-of-animation-features.html#space-things-out-with-stagger

Instead, your code should look like this:

animations: [
trigger('listAnimation', [
   transition('* => *', [
   // remember that :enter is a special
   // selector that will return each
   // newly inserted node in the ngFor list
   query(':enter', [
        style({
            transform: 'translate3d(0,-10px,0)',
            opacity: 0
        }),
        animate('0.1s', style({
            transform: 'translate3d(0,0,0)',
            opacity: 1
        }))
    ])
])  
]

This adds a level queryto what you already have.

0
source

, /. , for , div, /

-1

Source: https://habr.com/ru/post/1690858/


All Articles