mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
fix(virtual-scroll): read viewport size for every scroll event
This commit is contained in:
@ -125,7 +125,6 @@ export class VirtualScroll {
|
||||
}
|
||||
contentEl.componentOnReady().then(() => {
|
||||
this.scrollEl = contentEl.getScrollElement();
|
||||
this.calcDimensions();
|
||||
this.calcCells();
|
||||
this.updateState();
|
||||
});
|
||||
@ -147,7 +146,6 @@ export class VirtualScroll {
|
||||
@Listen('window:resize')
|
||||
onResize() {
|
||||
this.indexDirty = 0;
|
||||
this.calcDimensions();
|
||||
this.calcCells();
|
||||
this.updateVirtualScroll();
|
||||
}
|
||||
@ -232,6 +230,7 @@ export class VirtualScroll {
|
||||
}
|
||||
this.viewportOffset = topOffset;
|
||||
if (scrollEl) {
|
||||
this.viewportHeight = scrollEl.offsetHeight;
|
||||
this.currentScrollTop = scrollEl.scrollTop;
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
@ -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;
|
||||
|
Reference in New Issue
Block a user