v-infinite-scroll component displays a potentially infinite list, by loading more items of the list when scrolling. It supports either vertical or horizontal scrolling.
This feature requires v3.2.0 (Orion)
When scrolling towards the bottom, new items will be rendered either automatically, or manually with the click of a button.
A load event will be emitted when the component needs to load more content. The argument passed is an object with two properties.
sidetells you at which side new content should be added, either at the
'end'. The return value of the function is a string which describes if the new content was loaded successfully or not.
doneis a callback function that should be called when the loading of new content is done. It takes a single parameter
statusthat describes if the load was successful or not. See the table below for the possible values.
|Content was added succesfully|
|Something went wrong when adding content. This will display the |
|There is no more content to fetch. This will display the |
|Content is currently loading. This will display a message that content is loading. This status is only set internally by the component and should not be used with the done function|
The default behaviour of the component is to try to load more content automatically when the scrollbar gets close to the end. However a manual mode is also supported, where the user needs to do some interaction to load the content. By default this a button, but it can be customized with a slot
v-infinite-scroll component can be used with either vertical and horizontal scrolling.
By default the
v-infinite-scroll component assumes that new content will be appearing at the end of existing content. But it also supports content being added to the start, and content appearing both at the start and the end.
When using the start side for content, the scrolllbar will start at the bottom of the content.
When using both sides for content, the scrollbar will start in the middle of the content.
The default load more button and loading spinner can be colored with the color prop.
You can customize the loading message with the loading slot.
When using manual mode you can customize the action required to load more content with the load-more slot.
You can customize the empty message with the empty slot.
The error slot is shown if the status
'error' is returned from the
Virtualized infinite scroller
If the items in your infinite list are of a uniform size, you can quite easily virtualize the list to only render a small amount of items regardless of how far you scroll in either direction.