List
Scroll through long lists smoothly: Lynx draws only the rows near the screen. With *lynxListFor, Angular builds a row only as it scrolls into view, and reuses the rows scrolled away. So thousands of items stay fast.
<ui-list> wraps Lynx's <list> element with typed inputs, named outputs and a height you can set in one place.
Installation
Usage
- Wrap each row in a
<list-item>with a uniqueitem-key. Lynx uses the key to track and reuse rows, so never reuse a key for a different item. @forbuilds every row up front. For hundreds of rows or more, put*lynxListForon the<list-item>instead, with atrackBythat gives the key:<list-item *lynxListFor="let contact of contacts(); trackBy: byId">. It works in<ui-list>'s content. (<list recycle>recycles an@forin a<list>of your own template, so it doesn't reach<ui-list>'s.)- Give the list a fixed height, with
heightor a height class such ash-96. A list without one doesn't scroll. - The list fills its parent's width.
For a short list, a <scroll-view> is simpler and works as well.
Load more at the end
scrolledToEnd emits when the user nears the bottom. Append the next page there for infinite scroll.
lowerThresholdItemCountemitsscrolledToEndthat many items before the last one, so the next page arrives before the user hits the bottom.scrolledToStartandupperThresholdItemCountdo the same at the top.- Appending to a signal is safe here. Fetching data isn't supported from components yet (see Network requests).
Grid and masonry
listType="flow" lays rows out in a grid of spanCount columns. listType="waterfall" does the same with columns of uneven heights, like a photo wall.
mainAxisGap is the gap between rows along the scroll direction, and crossAxisGap the gap between columns. Set full-span on a <list-item>, such as a section header, to stretch it across every column.
Horizontal
API
UiList
Each input sets one <list> attribute, named in brackets.
Related
<list>: the element<ui-list>wraps, and<list-item><scroll-view>: a simpler scroller for short content- Pagination: show results in pages instead
