Skip to content

Commit

Permalink
fix(virtual-scroll): read viewport size for every scroll event
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Jul 11, 2018
1 parent 2127fa2 commit 1d3eb3f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions core/src/components/virtual-scroll/virtual-scroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export class VirtualScroll {
}
contentEl.componentOnReady().then(() => {
this.scrollEl = contentEl.getScrollElement();
this.calcDimensions();
this.calcCells();
this.updateState();
});
Expand All @@ -147,7 +146,6 @@ export class VirtualScroll {
@Listen('window:resize')
onResize() {
this.indexDirty = 0;
this.calcDimensions();
this.calcCells();
this.updateVirtualScroll();
}
Expand Down Expand Up @@ -232,6 +230,7 @@ export class VirtualScroll {
}
this.viewportOffset = topOffset;
if (scrollEl) {
this.viewportHeight = scrollEl.offsetHeight;
this.currentScrollTop = scrollEl.scrollTop;
}
}
Expand Down Expand Up @@ -313,8 +312,7 @@ export class VirtualScroll {
private updateState() {
const shouldEnable = !!(
this.scrollEl &&
this.cells &&
this.viewportHeight > 1
this.cells
);
if (shouldEnable !== this.isEnabled) {
this.enableScrollEvents(shouldEnable);
Expand Down Expand Up @@ -360,12 +358,6 @@ export class VirtualScroll {
this.indexDirty = Infinity;
}

private calcDimensions() {
if (this.scrollEl) {
this.viewportHeight = this.scrollEl.offsetHeight;
}
}

private enableScrollEvents(shouldListen: boolean) {
if (this.scrollEl) {
this.isEnabled = shouldListen;
Expand Down

0 comments on commit 1d3eb3f

Please sign in to comment.