I am trying to bind a variable in my angular component to a variable inside a CSS keyframe that I am using to animate a div dynamically. I came across HostBinding
as a potential solution however I (think) I followed the declaration correctly but the animation does not work when the variables are used. I am using angular 10.0.14 any help is appreciated.
This is my css code:
@keyframes swap{
0%{background-color:red; left: var(--inX);}
100%{background-color: red; left: var(--finX);}
}
And here this is my component.ts HostBinding declaration:
@Component({
selector: 'app-',
templateUrl: './component.html',
styleUrls: ['./component.css'],
})
export class Component implements OnInit {
@HostBinding('style.--inX')
private inX: string = '100px';
@HostBinding('style.--finX')
private finX:string = '200px';
}