Skip to content

Commit e072bb3

Browse files
authored
Merge branch 'master' into igxDragDrop-directive
2 parents 7738ba4 + 8e86eee commit e072bb3

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
249249
}
250250
}
251251

252-
public addScrollTop(addTop: number) {
252+
public addScrollTop(addTop: number): boolean {
253253
if (addTop === 0 && this.igxForScrollOrientation === 'horizontal') {
254-
return;
254+
return false;
255255
}
256-
256+
const originalVirtScrollTop = this._virtScrollTop;
257257
const containerSize = parseInt(this.igxForContainerSize, 10);
258258
const maxVirtScrollTop = this._virtHeight - containerSize;
259259

@@ -285,6 +285,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
285285
// Actual scroll position is not at the bottom, but virtual scroll is. Just update the acual scroll
286286
this.vh.instance.elementRef.nativeElement.scrollTop = maxRealScrollTop;
287287
}
288+
return this._virtScrollTop !== originalVirtScrollTop;
288289
}
289290

290291
public scrollTo(index) {

projects/igniteui-angular/src/lib/grid/cell.component.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
333333
});
334334
}
335335

336+
private performVerticalScroll(amout: number, rowIndex: number) {
337+
const scrolled = this.grid.verticalScrollContainer.addScrollTop(amout);
338+
if (scrolled) {
339+
this._focusNextCell(rowIndex, this.visibleColumnIndex);
340+
}
341+
}
342+
336343
@HostListener('dblclick', ['$event'])
337344
public onDoubleClick(event) {
338345
if (this.column.editable) {
@@ -589,16 +596,14 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
589596
&& verticalScroll.scrollTop // the scrollbar is not at the first item
590597
&& target.row.element.nativeElement.offsetTop < this.grid.rowHeight) { // the target is in the first row
591598

592-
this.grid.verticalScrollContainer.addScrollTop(-this.grid.rowHeight);
593-
this._focusNextCell(rowIndex, this.visibleColumnIndex);
599+
this.performVerticalScroll(-this.grid.rowHeight, rowIndex);
594600
}
595601
target.nativeElement.focus();
596602
} else {
597603
const scrollOffset =
598604
-parseInt(this.grid.verticalScrollContainer.dc.instance._viewContainer.element.nativeElement.style.top, 10);
599605
const scrollAmount = this.grid.rowHeight + scrollOffset;
600-
this.grid.verticalScrollContainer.addScrollTop(-scrollAmount);
601-
this._focusNextCell(this.rowIndex, this.visibleColumnIndex);
606+
this.performVerticalScroll(-scrollAmount, this.rowIndex);
602607
}
603608
}
604609

@@ -626,20 +631,17 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
626631
const targetEndTopOffset = target.row.element.nativeElement.offsetTop + this.grid.rowHeight + containerTopOffset;
627632
if (containerHeight && targetEndTopOffset > containerHeight) {
628633
const scrollAmount = targetEndTopOffset - containerHeight;
629-
this.grid.verticalScrollContainer.addScrollTop(scrollAmount);
630-
631-
this._focusNextCell(rowIndex, this.visibleColumnIndex);
634+
this.performVerticalScroll(scrollAmount, rowIndex);
632635
} else {
633636
target.nativeElement.focus();
634637
}
635638
} else {
636-
const containerHeight = this.grid.calcHeight;
637639
const contentHeight = this.grid.verticalScrollContainer.dc.instance._viewContainer.element.nativeElement.offsetHeight;
638640
const scrollOffset = parseInt(this.grid.verticalScrollContainer.dc.instance._viewContainer.element.nativeElement.style.top, 10);
639641
const lastRowOffset = contentHeight + scrollOffset - this.grid.calcHeight;
640642
const scrollAmount = this.grid.rowHeight + lastRowOffset;
641-
this.grid.verticalScrollContainer.addScrollTop(scrollAmount);
642-
this._focusNextCell(this.rowIndex, this.visibleColumnIndex);
643+
644+
this.performVerticalScroll(scrollAmount, this.rowIndex);
643645
}
644646
}
645647

0 commit comments

Comments
 (0)