feat(virtual-scroll): adds headerHeight and footerHeight (#18851)

Currently, if you have an ion-virtual-scroll with a list of items and a search bar for filtering them, when you change the list of items, the items disappear until rendered again, causing a flicker. This could be solved for the items using the itemHeight function to provide the exact height size and bypass some calculations and be more performant etc.

However, if you had a header or footer, they would still flicker. This commit adds two more optional functions named headerHeight and footerHeight that return the exact size of the header and footer respectively and resolve the flicker.
This commit is contained in:
Stefanos Anagnostou
2019-07-24 19:29:16 +03:00
committed by Manu MA
parent c91819c94f
commit 00891119f7
8 changed files with 72 additions and 16 deletions

View File

@ -20,8 +20,10 @@ import {
DatetimeChangeEventDetail,
DatetimeOptions,
DomRenderFn,
FooterHeightFn,
FrameworkDelegate,
HeaderFn,
HeaderHeightFn,
InputChangeEventDetail,
ItemHeightFn,
ItemRenderFn,
@ -2835,10 +2837,18 @@ export namespace Components {
*/
'footerFn'?: HeaderFn;
/**
* An optional function that maps each item footer within their height.
*/
'footerHeight'?: FooterHeightFn;
/**
* Section headers and the data used within its given template can be dynamically created by passing a function to `headerFn`. For example, a large list of contacts usually has dividers between each letter in the alphabet. App's can provide their own custom `headerFn` which is called with each record within the dataset. The logic within the header function can decide if the header template should be used, and what data to give to the header template. The function must return `null` if a header cell shouldn't be created.
*/
'headerFn'?: HeaderFn;
/**
* An optional function that maps each item header within their height.
*/
'headerHeight'?: HeaderHeightFn;
/**
* An optional function that maps each item within their height. When this function is provides, heavy optimizations and fast path can be taked by `ion-virtual-scroll` leading to massive performance improvements. This function allows to skip all DOM reads, which can be Doing so leads to massive performance
*/
'itemHeight'?: ItemHeightFn;
@ -6101,10 +6111,18 @@ declare namespace LocalJSX {
*/
'footerFn'?: HeaderFn;
/**
* An optional function that maps each item footer within their height.
*/
'footerHeight'?: FooterHeightFn;
/**
* Section headers and the data used within its given template can be dynamically created by passing a function to `headerFn`. For example, a large list of contacts usually has dividers between each letter in the alphabet. App's can provide their own custom `headerFn` which is called with each record within the dataset. The logic within the header function can decide if the header template should be used, and what data to give to the header template. The function must return `null` if a header cell shouldn't be created.
*/
'headerFn'?: HeaderFn;
/**
* An optional function that maps each item header within their height.
*/
'headerHeight'?: HeaderHeightFn;
/**
* An optional function that maps each item within their height. When this function is provides, heavy optimizations and fast path can be taked by `ion-virtual-scroll` leading to massive performance improvements. This function allows to skip all DOM reads, which can be Doing so leads to massive performance
*/
'itemHeight'?: ItemHeightFn;