#Why the cdk-virtual-port elementScrolled() event doesn't change my element style
6 messages · Page 1 of 1 (latest)
idk could be a change detection problem. Try to add private _cdr: ChangeDetectorRefin the constuctor and then call this._cdr.detectChanges();after console.log(this.headerBackground)
.
something about clean coding in this line this.scrollEvent$ = this.virtualScroll.elementScrolled().subscribe(data => {
usually the $ suffix is used for obsevables but in this case scrollEvent$ is a subscription (and not an observable).
in my optnion i prefer to call it scrollEventSubscription so it's clear that this is not an observable and you can't subscribe on it
Thank's it was working, but any performance pitfall by using this?
yes. You should check if the value has changed and then call detectChanges() so the performance won't be affected.
btw. I was wondering what is [style.--background] ? why not [style.background]? what's the difference?
it's CSS Custom Properties from IONIC :
https://ionicframework.com/docs/api/toolbar
Scroll to bottom