I am working on animations in Angular, and am running into an issue where the block will not fade out.
HTML in fadeblock:
<div class="fadeBlock mx-auto" [@changeState]="currentState"></div>
Component file:
import { Component, OnInit } from '@angular/core';
import { trigger, state, style, animate, transition, useAnimation } from
'@angular/animations';
import { fadeAnimation } from '../animations';
@Component({
selector: 'app-fadeblock',
templateUrl: './fadeblock.component.html',
styleUrls: [ './fadeblock.component.scss' ],
animations: [
trigger('changeState', [
transition('void => *', [
useAnimation(fadeAnimation, {
params: {
delay: '1000ms',
from: 1,
to: 0,
time: '1s'
}
})
])
])
]
})
export class FadeblockComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
and fadeAnimation:
import {
animation, trigger, animateChild, group,
transition, animate, style, query
} from '@angular/animations';
export const fadeAnimation = animation([
style({
opacity: '{{ from }}'
}),
animate('{{ time }} {{ delay }} ease-in-out', style({
opacity: '{{ to }}'
})),
]);
If I change the opacity in the css file, the block will just stay and not move. I get no errors when running ng serve, but do when I try to run ng build --prod
Any assistance is greatly appreciated as I try to learn Angular.