Skip to content

Commit 068c789

Browse files
fix(angular): change detection fix (#631)
1 parent 78c9dcd commit 068c789

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/simplebar-angular/src/lib/simplebar-angular.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
Input,
55
AfterViewInit,
66
ElementRef,
7-
ViewEncapsulation
7+
ViewEncapsulation,
8+
NgZone
89
} from '@angular/core';
910

1011
import SimpleBar from 'simplebar/dist/simplebar-core.esm';
@@ -26,14 +27,16 @@ export class SimplebarAngularComponent implements OnInit, AfterViewInit {
2627
elRef: ElementRef;
2728
SimpleBar: any;
2829

29-
constructor(elRef: ElementRef) {
30+
constructor(elRef: ElementRef, private zone: NgZone) {
3031
this.elRef = elRef;
3132
}
3233

3334
ngOnInit() {}
3435

3536
ngAfterViewInit(): void {
36-
this.SimpleBar = new SimpleBar(this.elRef.nativeElement, this.options || {});
37+
this.zone.runOutsideAngular(() => {
38+
this.SimpleBar = new SimpleBar(this.elRef.nativeElement, this.options || {});
39+
})
3740
}
3841

3942
ngOnDestroy() {

0 commit comments

Comments
 (0)