Skip to content

Commit 1d3eb3f

Browse files
committed
fix(virtual-scroll): read viewport size for every scroll event
1 parent 2127fa2 commit 1d3eb3f

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

core/src/components/virtual-scroll/virtual-scroll.tsx

+2-10
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export class VirtualScroll {
125125
}
126126
contentEl.componentOnReady().then(() => {
127127
this.scrollEl = contentEl.getScrollElement();
128-
this.calcDimensions();
129128
this.calcCells();
130129
this.updateState();
131130
});
@@ -147,7 +146,6 @@ export class VirtualScroll {
147146
@Listen('window:resize')
148147
onResize() {
149148
this.indexDirty = 0;
150-
this.calcDimensions();
151149
this.calcCells();
152150
this.updateVirtualScroll();
153151
}
@@ -232,6 +230,7 @@ export class VirtualScroll {
232230
}
233231
this.viewportOffset = topOffset;
234232
if (scrollEl) {
233+
this.viewportHeight = scrollEl.offsetHeight;
235234
this.currentScrollTop = scrollEl.scrollTop;
236235
}
237236
}
@@ -313,8 +312,7 @@ export class VirtualScroll {
313312
private updateState() {
314313
const shouldEnable = !!(
315314
this.scrollEl &&
316-
this.cells &&
317-
this.viewportHeight > 1
315+
this.cells
318316
);
319317
if (shouldEnable !== this.isEnabled) {
320318
this.enableScrollEvents(shouldEnable);
@@ -360,12 +358,6 @@ export class VirtualScroll {
360358
this.indexDirty = Infinity;
361359
}
362360

363-
private calcDimensions() {
364-
if (this.scrollEl) {
365-
this.viewportHeight = this.scrollEl.offsetHeight;
366-
}
367-
}
368-
369361
private enableScrollEvents(shouldListen: boolean) {
370362
if (this.scrollEl) {
371363
this.isEnabled = shouldListen;

0 commit comments

Comments
 (0)