Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Angular animation param with Host Binding

I have been trying to set animation param using @HostBinding decorative, but it seems not to work, what am I missing

animations: [
    trigger('animateMe', [
      state('void', style({ opacity: 0 })),
      transition(':enter, :leave', [ // void <=> *
        animate('{{ easeTime}}ms {{ transitionTimingFn }}')
      ])
    ])
  ]

and HostBinding

@HostBinding('@animateMe') state = {
    value: 'void',
    params: {
      easeTime: 5000
    }
  };
like image 462
Sibiraj Avatar asked Dec 14 '22 17:12

Sibiraj


1 Answers

If you add a getter function to the host binding property you can set the animation params.

trigger: any;
easingTime = 5000;

@HostBinding('@animateMe') 
get fn() {
    return {
        value: this.trigger,
        params: {
            easeTime: this.easingTime
        }
    }
};
like image 125
hyperdrive Avatar answered Dec 28 '22 01:12

hyperdrive