UNPKG

5.28 kBTypeScriptView Raw
1import { ElementRef, IterableDiffers, NgZone, SimpleChanges, TrackByFunction } from '@angular/core';
2import { FooterHeightFn, HeaderFn, HeaderHeightFn, ItemHeightFn } from '@ionic/core';
3import { VirtualFooter } from './virtual-footer';
4import { VirtualHeader } from './virtual-header';
5import { VirtualItem } from './virtual-item';
6export declare interface IonVirtualScroll {
7 /**
8 * It is important to provide this
9 * if virtual item height will be significantly larger than the default
10 * The approximate height of each virtual item template's cell.
11 * This dimension is used to help determine how many cells should
12 * be created when initialized, and to help calculate the height of
13 * the scrollable area. This height value can only use `px` units.
14 * Note that the actual rendered size of each cell comes from the
15 * app's CSS, whereas this approximation is used to help calculate
16 * initial dimensions before the item has been rendered.
17 */
18 approxItemHeight: number;
19 /**
20 * The approximate height of each header template's cell.
21 * This dimension is used to help determine how many cells should
22 * be created when initialized, and to help calculate the height of
23 * the scrollable area. This height value can only use `px` units.
24 * Note that the actual rendered size of each cell comes from the
25 * app's CSS, whereas this approximation is used to help calculate
26 * initial dimensions before the item has been rendered.
27 */
28 approxHeaderHeight: number;
29 /**
30 * The approximate width of each footer template's cell.
31 * This dimension is used to help determine how many cells should
32 * be created when initialized, and to help calculate the height of
33 * the scrollable area. This height value can only use `px` units.
34 * Note that the actual rendered size of each cell comes from the
35 * app's CSS, whereas this approximation is used to help calculate
36 * initial dimensions before the item has been rendered.
37 */
38 approxFooterHeight: number;
39 /**
40 * Section headers and the data used within its given
41 * template can be dynamically created by passing a function to `headerFn`.
42 * For example, a large list of contacts usually has dividers between each
43 * letter in the alphabet. App's can provide their own custom `headerFn`
44 * which is called with each record within the dataset. The logic within
45 * the header function can decide if the header template should be used,
46 * and what data to give to the header template. The function must return
47 * `null` if a header cell shouldn't be created.
48 */
49 headerFn?: HeaderFn;
50 /**
51 * Section footers and the data used within its given
52 * template can be dynamically created by passing a function to `footerFn`.
53 * The logic within the footer function can decide if the footer template
54 * should be used, and what data to give to the footer template. The function
55 * must return `null` if a footer cell shouldn't be created.
56 */
57 footerFn?: HeaderFn;
58 /**
59 * The data that builds the templates within the virtual scroll.
60 * It's important to note that when this data has changed, then the
61 * entire virtual scroll is reset, which is an expensive operation and
62 * should be avoided if possible.
63 */
64 items?: any[] | null;
65 /**
66 * An optional function that maps each item within their height.
67 * When this function is provided, heavy optimizations and fast path can be taked by
68 * `ion-virtual-scroll` leading to massive performance improvements.
69 *
70 * This function allows to skip all DOM reads, which can be Doing so leads
71 * to massive performance
72 */
73 itemHeight?: ItemHeightFn;
74 /**
75 * An optional function that maps each item header within their height.
76 */
77 headerHeight?: HeaderHeightFn;
78 /**
79 * An optional function that maps each item footer within their height.
80 */
81 footerHeight?: FooterHeightFn;
82 /**
83 * Same as `ngForTrackBy` which can be used on `ngFor`.
84 */
85 trackBy: TrackByFunction<any>;
86 /**
87 * This method marks the tail the items array as dirty, so they can be re-rendered. It's equivalent to calling: ```js * virtualScroll.checkRange(lastItemLen, items.length - lastItemLen); * ```
88 */
89 'checkEnd': () => void;
90 /**
91 * This method marks a subset of items as dirty, so they can be re-rendered. Items should be marked as dirty any time the content or their style changes. The subset of items to be updated can are specifing by an offset and a length.
92 */
93 'checkRange': (offset: number, len?: number) => void;
94 /**
95 * Returns the position of the virtual item at the given index.
96 */
97 'positionForItem': (index: number) => Promise<number>;
98}
99export declare class IonVirtualScroll {
100 private z;
101 private iterableDiffers;
102 private differ?;
103 private el;
104 private refMap;
105 itmTmp: VirtualItem;
106 hdrTmp: VirtualHeader;
107 ftrTmp: VirtualFooter;
108 constructor(z: NgZone, iterableDiffers: IterableDiffers, elementRef: ElementRef);
109 ngOnChanges(changes: SimpleChanges): void;
110 ngDoCheck(): void;
111 private nodeRender;
112 private getComponent;
113}