ui/ Virtual List
Unstyled virtual list components and behaviors to be customized by a theme or application.
import VirtualList from '@enact/ui/VirtualList';Members
VirtualListComponent
An unstyled scrollable virtual list component with touch support.
import VirtualList from '@enact/ui/VirtualList';Properties
A callback function that receives a reference to the
scrollTofeature.Once received, the
scrollTomethod can be called as an imperative interface.The
scrollTofunction accepts the following parameters:{position: {x, y}} - Pixel value for x and/or y position
{align} - Where the scroll area should be aligned. Values are:
'left','right','top','bottom','topleft','topright','bottomleft', and'bottomright'.{index} - Index of specific item. (
0or positive integer) This option is available for onlyVirtualListkind.{node} - Node to scroll into view
{animate} - When
true, scroll occurs with animation. Whenfalse, no animation occurs.{focus} - When
true, attempts to focus item after scroll. Only valid when scrolling byindexornode.
Note: Only specify one of:
position,align,indexornodeExample:
// If you set cbScrollTo prop like below; cbScrollTo: (fn) => {this.scrollTo = fn;} // You can simply call like below; this.scrollTo({align: 'top'}); // scroll to the topThe layout direction of the list.
Valid values are:
'horizontal', and'vertical'.
Default: 'vertical'Specifies how to show horizontal scrollbar.
Valid values are:
'auto','visible', and'hidden'.
Default: 'auto'Prevents scroll by wheeling on the list.
Default: falseCalled when scrolling.
Passes
scrollLeft,scrollTop, andmoreInfo. It is not recommended to set this prop since it can cause performance degradation. UseonScrollStartoronScrollStopinstead.Called when scroll starts.
Passes
scrollLeft,scrollTop, andmoreInfo. You can get firstVisibleIndex and lastVisibleIndex from VirtualList withmoreInfo.Example:
onScrollStart = ({scrollLeft, scrollTop, moreInfo}) => { const {firstVisibleIndex, lastVisibleIndex} = moreInfo; // do something with firstVisibleIndex and lastVisibleIndex } render = () => ( <VirtualList ... onScrollStart={this.onScrollStart} ... /> )Called when scroll stops.
Passes
scrollLeft,scrollTop, andmoreInfo. You can get firstVisibleIndex and lastVisibleIndex from VirtualList withmoreInfo.Example:
onScrollStop = ({scrollLeft, scrollTop, moreInfo}) => { const {firstVisibleIndex, lastVisibleIndex} = moreInfo; // do something with firstVisibleIndex and lastVisibleIndex } render = () => ( <VirtualList ... onScrollStop={this.onScrollStop} ... /> )The ARIA role for the list.
Default: 'list'Specifies how to scroll.
Valid values are:
'translate','native'.
Default: 'translate'Specifies how to show vertical scrollbar.
Valid values are:
'auto','visible', and'hidden'.
Default: 'auto'
VirtualGridListComponent
An unstyled scrollable virtual grid list component with touch support.
import {VirtualGridList} from '@enact/ui/VirtualList';Properties
A callback function that receives a reference to the
scrollTofeature.Once received, the
scrollTomethod can be called as an imperative interface.The
scrollTofunction accepts the following parameters:{position: {x, y}} - Pixel value for x and/or y position
{align} - Where the scroll area should be aligned. Values are:
'left','right','top','bottom','topleft','topright','bottomleft', and'bottomright'.{index} - Index of specific item. (
0or positive integer) This option is available for onlyVirtualListkind.{node} - Node to scroll into view
{animate} - When
true, scroll occurs with animation. Whenfalse, no animation occurs.{focus} - When
true, attempts to focus item after scroll. Only valid when scrolling byindexornode.
Note: Only specify one of:
position,align,indexornodeExample:
// If you set cbScrollTo prop like below; cbScrollTo: (fn) => {this.scrollTo = fn;} // You can simply call like below; this.scrollTo({align: 'top'}); // scroll to the topThe layout direction of the list.
Valid values are:
'horizontal', and'vertical'.
Default: 'vertical'Specifies how to show horizontal scrollbar.
Valid values are:
'auto','visible', and'hidden'.
Default: 'auto'Prevents scroll by wheeling on the list.
Default: falseCalled when scrolling.
Passes
scrollLeft,scrollTop, andmoreInfo. It is not recommended to set this prop since it can cause performance degradation. UseonScrollStartoronScrollStopinstead.Called when scroll starts.
Passes
scrollLeft,scrollTop, andmoreInfo. You can get firstVisibleIndex and lastVisibleIndex from VirtualGridList withmoreInfo.Example:
onScrollStart = ({scrollLeft, scrollTop, moreInfo}) => { const {firstVisibleIndex, lastVisibleIndex} = moreInfo; // do something with firstVisibleIndex and lastVisibleIndex } render = () => ( <VirtualGridList ... onScrollStart={this.onScrollStart} ... /> )Called when scroll stops.
Passes
scrollLeft,scrollTop, andmoreInfo. You can get firstVisibleIndex and lastVisibleIndex from VirtualList withmoreInfo.Example:
onScrollStop = ({scrollLeft, scrollTop, moreInfo}) => { const {firstVisibleIndex, lastVisibleIndex} = moreInfo; // do something with firstVisibleIndex and lastVisibleIndex } render = () => ( <VirtualGridList ... onScrollStop={this.onScrollStop} ... /> )The ARIA role for the list.
Default: 'list'Specifies how to scroll.
Valid values are:
'translate','native'.
Default: 'translate'Specifies how to show vertical scrollbar.
Valid values are:
'auto','visible', and'hidden'.
Default: 'auto'
VirtualListBaseComponent
A basic base component for VirtualList and VirtualGridList.
import {VirtualListBase} from '@enact/ui/VirtualList';Properties
The rendering function called for each item in the list.
Note: The list does not always render a component whenever its render function is called due to performance optimization.
Example:
renderItem = ({index, ...rest}) => { delete rest.data; return ( <MyComponent index={index} {...rest} /> ); }A callback function that receives a reference to the
scrollTofeature.Once received, the
scrollTomethod can be called as an imperative interface.The
scrollTofunction accepts the following parameters:{position: {x, y}} - Pixel value for x and/or y position
{align} - Where the scroll area should be aligned. Values are:
'left','right','top','bottom','topleft','topright','bottomleft', and'bottomright'.{index} - Index of specific item. (
0or positive integer) This option is available for onlyVirtualListkind.{node} - Node to scroll into view
{animate} - When
true, scroll occurs with animation. Whenfalse, no animation occurs.{focus} - When
true, attempts to focus item after scroll. Only valid when scrolling byindexornode.
Note: Only specify one of:
position,align,indexornodeExample:
// If you set cbScrollTo prop like below; cbScrollTo: (fn) => {this.scrollTo = fn;} // You can simply call like below; this.scrollTo({align: 'top'}); // scroll to the topAdditional props included in the object passed to the
itemsRenderercallback.Client size of the list; valid values are an object that has
clientWidthandclientHeight.The number of items of data the list contains.
Default: 0The layout direction of the list.
Valid values are:
'horizontal', and'vertical'.
Default: 'vertical'Specifies how to show horizontal scrollbar.
Valid values are:
'auto','visible', and'hidden'.
Default: 'auto'Prevents scroll by wheeling on the list.
Default: falseCalled when scrolling.
Passes
scrollLeft,scrollTop, andmoreInfo. It is not recommended to set this prop since it can cause performance degradation. UseonScrollStartoronScrollStopinstead.Called when scroll starts.
Passes
scrollLeft,scrollTop, andmoreInfo. You can get firstVisibleIndex and lastVisibleIndex from VirtualList withmoreInfo.Example:
onScrollStart = ({scrollLeft, scrollTop, moreInfo}) => { const {firstVisibleIndex, lastVisibleIndex} = moreInfo; // do something with firstVisibleIndex and lastVisibleIndex } render = () => ( <VirtualList ... onScrollStart={this.onScrollStart} ... /> )Called when scroll stops.
Passes
scrollLeft,scrollTop, andmoreInfo. You can get firstVisibleIndex and lastVisibleIndex from VirtualList withmoreInfo.Example:
onScrollStop = ({scrollLeft, scrollTop, moreInfo}) => { const {firstVisibleIndex, lastVisibleIndex} = moreInfo; // do something with firstVisibleIndex and lastVisibleIndex } render = () => ( <VirtualList ... onScrollStop={this.onScrollStop} ... /> )The spacing between items.
Default: 0Specifies how to show vertical scrollbar.
Valid values are:
'auto','visible', and'hidden'.
Default: 'auto'
VirtualListBasicComponent
A basic base component for VirtualList and VirtualGridList.
import {VirtualListBasic} from '@enact/ui/VirtualList';Properties
The rendering function called for each item in the list.
Note: The list does not always render a component whenever its render function is called due to performance optimization.
Example:
renderItem = ({index, ...rest}) => { return ( <MyComponent index={index} {...rest} /> ); }Additional props included in the object passed to the
itemRenderercallback.Client size of the list; valid values are an object that has
clientWidthandclientHeight.The number of items of data the list contains.
Default: 0The layout direction of the list.
Valid values are:
'horizontal', and'vertical'.
Default: 'vertical'The ARIA role for the list.
Default: 'list'Specifies how to scroll.
Valid values are:
'translate','native'.
Default: 'translate'The spacing between items.
Default: 0
Type Definitions
gridListItemSizeShapeObject
The shape for the grid list item size in a list for VirtualGridList.
- minWidth •
- Number
The minimum width of the grid list item.
- minHeight •
- Number
The minimum height of the grid list item.
itemSizesShapeObject
The shape for the list different item size in a list for VirtualList.
- minSize •
- Number
The minimum size of the list item.
- size •
- ArrayNumber
An array of the list item size. If it is not defined, the list items will render with the
minSizesize.