From dc100c44bef5390f9f3ddc48551effe4df9692c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Thu, 18 Nov 2021 21:48:31 +0200 Subject: [PATCH] Has scrollbar change detection fix --- src/lib/scrollbar/has-scrollbar.directive.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/scrollbar/has-scrollbar.directive.ts b/src/lib/scrollbar/has-scrollbar.directive.ts index d72c4cb..2c4d319 100644 --- a/src/lib/scrollbar/has-scrollbar.directive.ts +++ b/src/lib/scrollbar/has-scrollbar.directive.ts @@ -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(); } }