Skip to content

Commit cf4b78d

Browse files
authored
Merge pull request #7319 from IgniteUI/mkirova/fix-7234-8.2.x
fix(virtualization): Use virtual scroll top which takes virtual heig
2 parents ff3bb4c + 1d588fc commit cf4b78d

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -716,13 +716,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
716716
if (!parseInt(this.scrollComponent.nativeElement.style.height, 10)) {
717717
return;
718718
}
719-
720-
const containerSize = parseInt(this.igxForContainerSize, 10);
721-
const maxRealScrollTop = event.target.children[0].scrollHeight - containerSize;
722-
const realPercentScrolled = maxRealScrollTop !== 0 ? event.target.scrollTop / maxRealScrollTop : 0;
723719
if (!this._bScrollInternal) {
724-
const maxVirtScrollTop = this._virtHeight - containerSize;
725-
this._virtScrollTop = realPercentScrolled * maxVirtScrollTop;
720+
this._calcVirtualScrollTop(event.target.scrollTop);
726721
} else {
727722
this._bScrollInternal = false;
728723
}
@@ -1289,11 +1284,25 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
12891284
}
12901285
private _updateVScrollOffset() {
12911286
let scrollOffset = 0;
1287+
let currentScrollTop = this.scrollPosition;
1288+
if (this._virtHeightRatio !== 1) {
1289+
this._calcVirtualScrollTop(this.scrollPosition);
1290+
currentScrollTop = this._virtScrollTop;
1291+
}
12921292
const vScroll = this.scrollComponent.nativeElement;
12931293
scrollOffset = vScroll && this.scrollComponent.size ?
1294-
this.scrollPosition - this.sizesCache[this.state.startIndex] : 0;
1294+
currentScrollTop - this.sizesCache[this.state.startIndex] : 0;
12951295
this.dc.instance._viewContainer.element.nativeElement.style.top = -(scrollOffset) + 'px';
12961296
}
1297+
1298+
protected _calcVirtualScrollTop(scrollTop: number) {
1299+
const containerSize = parseInt(this.igxForContainerSize, 10);
1300+
const maxRealScrollTop = this.scrollComponent.size - containerSize;
1301+
const realPercentScrolled = maxRealScrollTop !== 0 ? scrollTop / maxRealScrollTop : 0;
1302+
const maxVirtScrollTop = this._virtHeight - containerSize;
1303+
this._virtScrollTop = realPercentScrolled * maxVirtScrollTop;
1304+
}
1305+
12971306
private _updateHScrollOffset() {
12981307
let scrollOffset = 0;
12991308
scrollOffset = this.scrollComponent.nativeElement &&
@@ -1564,13 +1573,8 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
15641573
if (!parseInt(this.scrollComponent.nativeElement.style.height, 10)) {
15651574
return;
15661575
}
1567-
1568-
const containerSize = parseInt(this.igxForContainerSize, 10);
1569-
const maxRealScrollTop = event.target.children[0].scrollHeight - containerSize;
1570-
const realPercentScrolled = maxRealScrollTop !== 0 ? event.target.scrollTop / maxRealScrollTop : 0;
15711576
if (!this._bScrollInternal) {
1572-
const maxVirtScrollTop = this._virtHeight - containerSize;
1573-
this._virtScrollTop = realPercentScrolled * maxVirtScrollTop;
1577+
this._calcVirtualScrollTop(event.target.scrollTop);
15741578
} else {
15751579
this._bScrollInternal = false;
15761580
}

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,9 +2845,9 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
28452845
expect(GridFunctions.getCurrentCellFromGrid(grid, 1, 1).value).toBe('Ignite UI for Angular');
28462846
}));
28472847

2848-
it('Verify filter cell chip is scrolled into view on click.', fakeAsync(() => {
2848+
it('Verify filter cell chip is scrolled into view on click.', async () => {
28492849
grid.width = '470px';
2850-
tick(100);
2850+
await wait(30);
28512851
fix.detectChanges();
28522852

28532853
// Verify 'ReleaseDate' filter chip is not fully visible.
@@ -2858,11 +2858,11 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
28582858
'chip should not be fully visible and thus not within grid');
28592859

28602860
GridFunctions.clickFilterCellChip(fix, 'ReleaseDate');
2861-
tick(100);
2861+
await wait(30);
28622862
fix.detectChanges();
28632863

2864-
GridFunctions.closeFilterRow(fix);
2865-
tick(100);
2864+
grid.filteringRow.close();
2865+
await wait();
28662866
fix.detectChanges();
28672867

28682868
// Verify 'ReleaseDate' filter chip is fully visible.
@@ -2871,7 +2871,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
28712871
gridRect = grid.nativeElement.getBoundingClientRect();
28722872
expect(chipRect.left > gridRect.left && chipRect.right < gridRect.right).toBe(true,
28732873
'chip should be fully visible and within grid');
2874-
}));
2874+
});
28752875

28762876
it('Verify condition chips are scrolled into/(out of) view by using arrow buttons.', (async () => {
28772877
grid.width = '700px';

0 commit comments

Comments
 (0)