From 51c398d61432cfa48a79f3b956cabbb138ffb3f4 Mon Sep 17 00:00:00 2001 From: Michael Asimakopoulos Date: Mon, 30 Jan 2017 12:07:41 +0200 Subject: [PATCH] fix(virtualscroll): Populate nodes at correct height --- .../virtual-scroll/virtual-scroll.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/virtual-scroll/virtual-scroll.ts b/src/components/virtual-scroll/virtual-scroll.ts index ee733f77e76..983ff6a82f6 100644 --- a/src/components/virtual-scroll/virtual-scroll.ts +++ b/src/components/virtual-scroll/virtual-scroll.ts @@ -432,7 +432,8 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy { writeUpdate() { console.debug(`virtual-scroll, writeUpdate`); - processRecords(this._data.renderHeight, + const stopAtHeight = ((this._data.scrollTop || 0) + this._data.renderHeight); + processRecords(stopAtHeight, this._records, this._cells, this._hdrFn, @@ -458,16 +459,17 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy { const records = this._records; // initialize nodes with the correct cell data - data.topCell = 0; + adjustRendered(cells, data); data.bottomCell = (cells.length - 1); - populateNodeData(0, data.bottomCell, - data.viewWidth, true, - cells, records, nodes, - this._itmTmp.viewContainer, - this._itmTmp.templateRef, - this._hdrTmp && this._hdrTmp.templateRef, - this._ftrTmp && this._ftrTmp.templateRef, true); + populateNodeData(data.topCell || 0, + data.bottomCell, + data.viewWidth, true, + cells, records, nodes, + this._itmTmp.viewContainer, + this._itmTmp.templateRef, + this._hdrTmp && this._hdrTmp.templateRef, + this._ftrTmp && this._ftrTmp.templateRef, true); // ******** DOM WRITE **************** this._cd.detectChanges();