mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 13:32:54 +08:00
fix(virtual-scroll): working in angular
This commit is contained in:
@ -53,9 +53,9 @@
|
||||
return el;
|
||||
}
|
||||
|
||||
virtual.itemRender = (el, item, type) => {
|
||||
if (type === 0) return renderItem(el, item);
|
||||
return renderHeader(el, item);
|
||||
virtual.itemRender = (el, cell) => {
|
||||
if (cell.type === 0) return renderItem(el, cell.value);
|
||||
return renderHeader(el, cell.value);
|
||||
};
|
||||
virtual.items = Array.from({length: 1000}, (x, i) => i);
|
||||
};
|
||||
|
@ -61,9 +61,9 @@
|
||||
return el;
|
||||
}
|
||||
|
||||
virtual.itemRender = (el, item, type) => {
|
||||
if (type === 0) return renderItem(el, item);
|
||||
return renderHeader(el, item);
|
||||
virtual.itemRender = (el, cell) => {
|
||||
if (cell.type === 0) return renderItem(el, cell.value);
|
||||
return renderHeader(el, cell.value);
|
||||
};
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ export interface VirtualNode {
|
||||
export type NodeHeightFn = (node: VirtualNode, index: number) => number;
|
||||
export type HeaderFn = (item: any, index: number, items: any[]) => string | null;
|
||||
export type ItemHeightFn = (item: any, index?: number) => number;
|
||||
export type ItemRenderFn = (el: HTMLElement|null, item: any, type: CellType, index?: number) => HTMLElement;
|
||||
export type ItemRenderFn = (el: HTMLElement|null, cell: Cell, domIndex?: number) => HTMLElement;
|
||||
export type DomRenderFn = (dom: VirtualNode[], height: number) => void;
|
||||
|
||||
export function updateVDom(dom: VirtualNode[], heightIndex: Uint32Array, cells: Cell[], top: number, bottom: number) {
|
||||
@ -84,9 +84,9 @@ export function doRender(el: HTMLElement, itemRender: ItemRenderFn, dom: Virtual
|
||||
if (node.change === 2) {
|
||||
if (i < children.length) {
|
||||
child = children[i] as HTMLElement;
|
||||
itemRender(child, cell.value, cell.type, cell.index);
|
||||
itemRender(child, cell, i);
|
||||
} else {
|
||||
child = itemRender(null, cell.value, cell.type, cell.index);
|
||||
child = itemRender(null, cell, i);
|
||||
child.classList.add('virtual-item');
|
||||
el.appendChild(child);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ export class VirtualScroll {
|
||||
private updateState() {
|
||||
const shouldEnable = !!(
|
||||
this.scrollEl &&
|
||||
this.items &&
|
||||
this.cells &&
|
||||
(this.itemRender || this.domRender) &&
|
||||
this.viewportHeight > 1
|
||||
);
|
||||
|
Reference in New Issue
Block a user