Skip to content

Commit

Permalink
Merge pull request #7711 from IgniteUI/skrastev/fix-7702-10.0.x
Browse files Browse the repository at this point in the history
fix(igxForOf): Cache scroll size on initialize and use cached value when scrolling.
  • Loading branch information
kdinev authored Jun 30, 2020
2 parents fe3a767 + 83037f5 commit fd56e2f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class VirtualHelperBaseDirective implements OnDestroy, AfterViewInit {
public destroyed;

private _afterViewInit = false;
private _scrollNativeSize: number;

ngAfterViewInit() {
this._afterViewInit = true;
Expand All @@ -29,7 +30,9 @@ export class VirtualHelperBaseDirective implements OnDestroy, AfterViewInit {
onScroll(event) {
this.scrollAmount = event.target.scrollTop || event.target.scrollLeft;
}
constructor(public elementRef: ElementRef, public cdr: ChangeDetectorRef) { }
constructor(public elementRef: ElementRef, public cdr: ChangeDetectorRef) {
this._scrollNativeSize = this.calculateScrollNativeSize();
}

get nativeElement() {
return this.elementRef.nativeElement;
Expand All @@ -54,6 +57,10 @@ export class VirtualHelperBaseDirective implements OnDestroy, AfterViewInit {
}

public get scrollNativeSize() {
return this._scrollNativeSize;
}

public calculateScrollNativeSize() {
const div = document.createElement('div');
const style = div.style;
style.width = '100px';
Expand Down

0 comments on commit fd56e2f

Please sign in to comment.