Has scrollbar change detection fix
This commit is contained in:
parent
73982bba19
commit
dc100c44be
@ -1,4 +1,4 @@
|
||||
import { Directive, ElementRef, HostBinding, HostListener, OnChanges, OnInit } from '@angular/core';
|
||||
import { ChangeDetectorRef, Directive, ElementRef, HostBinding, HostListener, OnChanges, OnInit } from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[iqserHasScrollbar]',
|
||||
@ -7,7 +7,7 @@ import { Directive, ElementRef, HostBinding, HostListener, OnChanges, OnInit } f
|
||||
export class HasScrollbarDirective implements OnInit, OnChanges {
|
||||
@HostBinding('class') class = '';
|
||||
|
||||
constructor(private readonly _elementRef: ElementRef) {}
|
||||
constructor(private readonly _elementRef: ElementRef, private readonly _changeDetector: ChangeDetectorRef) {}
|
||||
|
||||
get hasScrollbar(): boolean {
|
||||
const element = this._elementRef?.nativeElement as HTMLElement;
|
||||
@ -25,6 +25,7 @@ export class HasScrollbarDirective implements OnInit, OnChanges {
|
||||
const newClass = this.hasScrollbar ? 'has-scrollbar' : '';
|
||||
if (this.class !== newClass) {
|
||||
this.class = newClass;
|
||||
this._changeDetector.markForCheck();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user