0
I’m trying to put a fadein/fadeout effect, but it’s only working the fadein, when it happens the element disappears instantly.
I tried to:
@Component({
selector: 'app-confprecificacao',
templateUrl: './confprecificacao.component.html',
styleUrls: ['./confprecificacao.component.scss'],
animations: [
trigger('fadeInOut', [
transition(':enter', [ // :enter is alias to 'void => *'
style({opacity:0}),
animate(500, style({opacity:1}))
]),
transition(':leave', [ // :leave is alias to '* => void'
animate(500, style({opacity:0}))
])
])
]
})
My template:
<div [ngClass]="{'transition':loadingcadastro}" [hidden]="!loadingcadastro" [@fadeInOut] id="controlaloading" class="controleloading">
<app-loading></app-loading>
</div>
I switched to:
<div [@hideShowAnimator]="loadingcadastro" id="controlaloading" class="controleloading">
<app-loading></app-loading>
</div>
and:
trigger('hideShowAnimator', [
state('true' , style({ opacity: 1 })),
state('false', style({ opacity: 0 })),
transition('0 => 1', animate('.5s')),
transition('1 => 0', animate('.5s'))
])
But now fadein doesn’t happen.
Dude, I’m no expert, but you have to put in the initial state and not the ending? Type no :Leave has to be: style({opacity:1}), Animate(500, style({opacity:0})) ?
– hugocsl
I switched by placing the states but now the fadein doesn’t happen. Trigger('hideShowAnimator', [ state('true' , style({ opacity: 1 })), state('false', style({ opacity: 0 })), Transition('0 => 1', Animate('. 5s'), Transition('1 =>>
– veroneseComS
And I don’t think I can help much :/ as I said it was just a tip for you to test rss
– hugocsl
thanks anyway
– veroneseComS