Method VirtualList
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
VirtualList<T>(IReadOnlyList<T>, Func<T, string>, float, Func<T, VNode>, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)
Creates a vertical virtualized list.
public static VirtualListNode VirtualList<T>(IReadOnlyList<T> items, Func<T, string> keySelector, float itemHeight, Func<T, VNode> renderer, int overscan = 3, string? key = null, string? className = null, string? name = null, Ref<VirtualListHandle>? listRef = null, FiberEventBinding[]? events = null)
Parameters
itemsIReadOnlyList<T>Source collection.
keySelectorFunc<T, string>Selector that derives a per-item key.
itemHeightfloatItem height in pixels.
rendererFunc<T, VNode>Builds each rendered item.
overscanintExtra items rendered beyond each edge.
keystringThe list's key among its siblings.
classNamestringUtility classes for the list.
namestringThe list element's name.
listRefRef<VirtualListHandle>Receives the mounted list's handle.
eventsFiberEventBinding[]Event bindings applied to the list's ScrollView (
Documentation~/react-migration.mdowns the rule). The array is read and never written.
Returns
Type Parameters
TElement type of the source collection.
VirtualList<T>(IReadOnlyList<T>, Func<T, string>, float, Func<T, VNode>, bool, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)
Virtualized list component for rendering large item collections. Renders a ScrollView of items of one height and only places the visible range in the DOM (a virtualized list).
public static VirtualListNode VirtualList<T>(IReadOnlyList<T> items, Func<T, string> keySelector, float itemHeight, Func<T, VNode> renderer, bool horizontal, int overscan = 3, string? key = null, string? className = null, string? name = null, Ref<VirtualListHandle>? listRef = null, FiberEventBinding[]? events = null)
Parameters
itemsIReadOnlyList<T>Source collection. Must not be null.
keySelectorFunc<T, string>Selector that derives a stable per-item key. Must not be null. The key is compared only with the other keys of this list, so it is not held to Key's rule on what a key may contain. A null key is no key, the answer List<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>) gives the same selector: the row renders, and a range change reuses it by its item index. Items sharing a key all render and are told apart by their item index, each keeping the row rendered at its own index while it stays in the range; two of them rendered in one range log a warning naming the key.
itemHeightfloatHeight (pixels) of every item, used for layout and visible-range calculation.
rendererFunc<T, VNode>Function that produces a VNode for each visible item. Must not be null. A key it sets on the node it returns plays no part in which row a range change reuses —
keySelector's key does — and the node is left as the renderer returned it, so one node returned for several items does not merge their rows. A throw of its own is not contained — it reaches the caller, and the range update it ends leaves the list showing no rows.horizontalboolLay the items out in a row and scroll the list sideways, FlashList's
horizontal;itemHeightis then each item's width.overscanintExtra items rendered above/below the visible window to smooth scroll-in.
keystringKey used to disambiguate siblings at the same position.
classNamestringCSS-like utility class string. Multiple classes separated by spaces.
namestringElement name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.
listRefRef<VirtualListHandle>Ref set to the list's VirtualListHandle while it is mounted.
eventsFiberEventBinding[]Event bindings applied to the list's ScrollView (
Documentation~/react-migration.mdowns the rule). The array is read and never written.
Returns
- VirtualListNode
The created VirtualListNode.
Type Parameters
TElement type of the source collection.
Exceptions
- ArgumentException
Thrown when
keycontains a NUL character.
VirtualList<T>(IReadOnlyList<T>, Func<T, string>, Func<int, float>, Func<T, VNode>, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)
Creates a vertical virtualized list.
public static VirtualListNode VirtualList<T>(IReadOnlyList<T> items, Func<T, string> keySelector, Func<int, float> itemHeight, Func<T, VNode> renderer, int overscan = 3, string? key = null, string? className = null, string? name = null, Ref<VirtualListHandle>? listRef = null, FiberEventBinding[]? events = null)
Parameters
itemsIReadOnlyList<T>Source collection.
keySelectorFunc<T, string>Selector that derives a per-item key.
itemHeightFunc<int, float>Item height in pixels at an index.
rendererFunc<T, VNode>Builds each rendered item.
overscanintExtra items rendered beyond each edge.
keystringThe list's key among its siblings.
classNamestringUtility classes for the list.
namestringThe list element's name.
listRefRef<VirtualListHandle>Receives the mounted list's handle.
eventsFiberEventBinding[]Event bindings applied to the list's ScrollView (
Documentation~/react-migration.mdowns the rule). The array is read and never written.
Returns
Type Parameters
TElement type of the source collection.
VirtualList<T>(IReadOnlyList<T>, Func<T, string>, Func<int, float>, Func<T, VNode>, bool, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)
Virtualized list whose items each take the height itemHeight gives for their
index — react-window's rowHeight function. Every other parameter is
VirtualList<T>(IReadOnlyList<T>, Func<T, string>, float, Func<T, VNode>, bool, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)'s.
public static VirtualListNode VirtualList<T>(IReadOnlyList<T> items, Func<T, string> keySelector, Func<int, float> itemHeight, Func<T, VNode> renderer, bool horizontal, int overscan = 3, string? key = null, string? className = null, string? name = null, Ref<VirtualListHandle>? listRef = null, FiberEventBinding[]? events = null)
Parameters
itemsIReadOnlyList<T>Source collection. Must not be null.
keySelectorFunc<T, string>Selector that derives a stable per-item key. Must not be null.
itemHeightFunc<int, float>Height (pixels) of the item at an index. Must not be null. It is asked for every item each time the list renders.
rendererFunc<T, VNode>Function that produces a VNode for each visible item. Must not be null.
horizontalboolLay the items out in a row and scroll the list sideways, FlashList's
horizontal;itemHeightis then each item's width.overscanintExtra items rendered above/below the visible window to smooth scroll-in.
keystringKey used to disambiguate siblings at the same position.
classNamestringCSS-like utility class string. Multiple classes separated by spaces.
namestringElement name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.
listRefRef<VirtualListHandle>Ref set to the list's VirtualListHandle while it is mounted.
eventsFiberEventBinding[]Event bindings applied to the list's ScrollView (
Documentation~/react-migration.mdowns the rule). The array is read and never written.
Returns
- VirtualListNode
The created VirtualListNode.
Type Parameters
TElement type of the source collection.
Exceptions
- ArgumentException
Thrown when
keycontains a NUL character.