Luis Airabella
Luis Airabella

Reputation: 23

Input Animation when value changes Angular 2+

Hello im new with angular animations, i want to make my input animated when input value changes (is a calculator). I have done this, how can shoot an event to execute the animation?

@Component({
    selector: 'xxxxx',
    templateUrl: './yyyy.html',
    styleUrls: ['./example.scss'],
    animations: [
        trigger('simpleFadeAnimation', [
            state('in', style({opacity: 1})),
            transition(':enter', [
                style({opacity: 0}),
                animate(600)
            ])
        ])
    ]
})

Upvotes: 2

Views: 1695

Answers (1)

Eliseo
Eliseo

Reputation: 57981

you can use wild cards

animations: [
        trigger('simpleFadeAnimation', [
            transition('*=>*', [
                style({opacity: 0}),
                animate(600)
            ])
        ])
    ]

So, you can use

<div [@simpleFadeAnimation]="value">
.....some...
</div>

Each time you change the variable "value", the animation begings

Upvotes: 4

Related Questions