mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
@ -20,6 +20,10 @@
|
|||||||
<ion-button onclick="addItems()">Add Items</ion-button>
|
<ion-button onclick="addItems()">Add Items</ion-button>
|
||||||
</ion-buttons>
|
</ion-buttons>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
|
<ion-toolbar></ion-toolbar>
|
||||||
|
<ion-toolbar></ion-toolbar>
|
||||||
|
<ion-toolbar></ion-toolbar>
|
||||||
|
<ion-toolbar></ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
@ -11,6 +11,7 @@ import { Range, calcCells, calcHeightIndex, doRender, findCellIndex, getRange, g
|
|||||||
})
|
})
|
||||||
export class VirtualScroll {
|
export class VirtualScroll {
|
||||||
|
|
||||||
|
private contentEl?: HTMLElement;
|
||||||
private scrollEl?: HTMLElement;
|
private scrollEl?: HTMLElement;
|
||||||
private range: Range = { offset: 0, length: 0 };
|
private range: Range = { offset: 0, length: 0 };
|
||||||
private timerUpdate: any;
|
private timerUpdate: any;
|
||||||
@ -121,6 +122,7 @@ export class VirtualScroll {
|
|||||||
}
|
}
|
||||||
await contentEl.componentOnReady();
|
await contentEl.componentOnReady();
|
||||||
|
|
||||||
|
this.contentEl = contentEl;
|
||||||
this.scrollEl = contentEl.getScrollElement();
|
this.scrollEl = contentEl.getScrollElement();
|
||||||
this.calcCells();
|
this.calcCells();
|
||||||
this.updateState();
|
this.updateState();
|
||||||
@ -215,14 +217,15 @@ export class VirtualScroll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readVS() {
|
private readVS() {
|
||||||
const { scrollEl, el } = this;
|
const { contentEl, scrollEl, el } = this;
|
||||||
let topOffset = 0;
|
let topOffset = 0;
|
||||||
let node: HTMLElement | null = el;
|
let node: HTMLElement | null = el;
|
||||||
while (node && node !== scrollEl) {
|
while (node && node !== contentEl) {
|
||||||
topOffset += node.offsetTop;
|
topOffset += node.offsetTop;
|
||||||
node = node.parentElement;
|
node = node.parentElement;
|
||||||
}
|
}
|
||||||
this.viewportOffset = topOffset;
|
this.viewportOffset = topOffset;
|
||||||
|
console.log(this.viewportOffset);
|
||||||
if (scrollEl) {
|
if (scrollEl) {
|
||||||
this.viewportHeight = scrollEl.offsetHeight;
|
this.viewportHeight = scrollEl.offsetHeight;
|
||||||
this.currentScrollTop = scrollEl.scrollTop;
|
this.currentScrollTop = scrollEl.scrollTop;
|
||||||
|
Reference in New Issue
Block a user