Skip to content

Commit

Permalink
NAS-130759: Use same instance on destroy and on init for tree-virtual…
Browse files Browse the repository at this point in the history
…-scroll-view event sub (#10532)
  • Loading branch information
RehanY147 authored Aug 23, 2024
1 parent 607cf1f commit d0b38d9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ export class TreeVirtualScrollViewComponent<T> extends Tree<T> implements OnChan
override ngOnInit(): void {
this.scrollableElement = document.querySelector('.rightside-content-hold');
if (this.scrollableElement) {
this.scrollableElement.addEventListener('scroll', this.scrolled.bind(this));
this.scrollableElement.addEventListener('scroll', this.scrolled);
}
}

override ngOnDestroy(): void {
if (this.scrollableElement) {
this.scrollableElement.removeEventListener('scroll', this.scrolled.bind(this));
this.scrollableElement.removeEventListener('scroll', this.scrolled);
}
}

Expand Down Expand Up @@ -131,7 +131,7 @@ export class TreeVirtualScrollViewComponent<T> extends Tree<T> implements OnChan
});
}

private scrolled(): void {
private readonly scrolled = (): void => {
this.viewportScrolled.emit(this.virtualScrollViewport.elementRef.nativeElement.scrollLeft);
}
};
}

0 comments on commit d0b38d9

Please sign in to comment.