react-virtualized#WindowScroller TypeScript Examples
The following examples show how to use
react-virtualized#WindowScroller.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SessionList.tsx From lightning-terminal with MIT License | 5 votes |
SessionList: React.FC = () => {
const { sessionStore } = useStore();
if (sessionStore.sortedSessions.length === 0) return null;
const { Wrapper } = Styled;
return (
<Wrapper>
<SessionRowHeader />
<ListContainer>
<AutoSizer disableHeight>
{({ width }) => (
<WindowScroller>
{({ height, isScrolling, onChildScroll, scrollTop, registerChild }) => (
<Observer>
{() => (
<div ref={ref => ref && registerChild(ref)}>
<List
autoHeight
height={height}
isScrolling={isScrolling}
onScroll={onChildScroll}
rowCount={sessionStore.sortedSessions.length}
rowHeight={ROW_HEIGHT}
rowRenderer={({ index, key, style }) => (
<SessionRow
key={key}
style={style}
session={sessionStore.sortedSessions[index]}
/>
)}
scrollTop={scrollTop}
width={width}
/>
</div>
)}
</Observer>
)}
</WindowScroller>
)}
</AutoSizer>
</ListContainer>
</Wrapper>
);
}
Example #2
Source File: HistoryList.tsx From lightning-terminal with MIT License | 5 votes |
HistoryList: React.FC = () => {
const { swapStore } = useStore();
const { Wrapper } = Styled;
return (
<Wrapper>
<HistoryRowHeader />
<ListContainer>
<AutoSizer disableHeight>
{({ width }) => (
<WindowScroller>
{({ height, isScrolling, onChildScroll, scrollTop, registerChild }) => (
<Observer>
{() => (
<div ref={ref => ref && registerChild(ref)}>
<List
autoHeight
height={height}
isScrolling={isScrolling}
onScroll={onChildScroll}
rowCount={swapStore.sortedSwaps.length}
rowHeight={ROW_HEIGHT}
rowRenderer={({ index, key, style }) => (
<HistoryRow
key={key}
style={style}
swap={swapStore.sortedSwaps[index]}
/>
)}
scrollTop={scrollTop}
width={width}
/>
</div>
)}
</Observer>
)}
</WindowScroller>
)}
</AutoSizer>
</ListContainer>
</Wrapper>
);
}
Example #3
Source File: ChannelList.tsx From lightning-terminal with MIT License | 5 votes |
ChannelList: React.FC = () => {
const { buildSwapView } = useStore();
const { Wrapper, ListContainer } = Styled;
return (
<Wrapper data-tour="channel-list">
<ChannelRowHeader />
<ListContainer>
<AutoSizer disableHeight>
{({ width }) => (
<WindowScroller>
{({ height, isScrolling, onChildScroll, scrollTop, registerChild }) => (
<Observer>
{() => (
<div ref={ref => ref && registerChild(ref)}>
<List
autoHeight
height={height}
isScrolling={isScrolling}
onScroll={onChildScroll}
rowCount={buildSwapView.channels.length}
rowHeight={ROW_HEIGHT}
rowRenderer={({ index, key, style }) => (
<ChannelRow
key={key}
style={style}
channel={buildSwapView.channels[index]}
/>
)}
scrollTop={scrollTop}
width={width}
/>
</div>
)}
</Observer>
)}
</WindowScroller>
)}
</AutoSizer>
</ListContainer>
</Wrapper>
);
}
Example #4
Source File: IconList.tsx From iconsax-react with MIT License | 5 votes |
IconList = () => {
const [filtered, setFiltered] = useState<IIconsArray[]>(icons)
const [numColumns, setNumColumns] = useState(1)
const query = searchStore((state) => state.query)
const onResize = ({ width }: { width: number }) => {
if (width <= 576) {
setNumColumns(Math.floor(width / ICON_CONTAINER_SIZE))
} else {
setNumColumns(Math.floor(width / ICON_CONTAINER_SIZE))
}
}
useEffect(() => {
console.log(query)
const f =
icons.filter((x) =>
x.name.toLowerCase().includes(query!.toLowerCase())
) || []
setFiltered(f)
}, [query])
return (
<div className="container flex justify-center m-auto min-h-[400px]">
<div className="w-full relative mb-10">
{filtered.length > 0 ? (
<WindowScroller>
{({ height, isScrolling, onChildScroll, scrollTop }) => (
<AutoSizer disableHeight onResize={onResize}>
{({ width }) => (
<List
tabIndex={-1}
autoHeight
width={width}
height={height}
isScrolling={isScrolling}
onScroll={onChildScroll}
scrollTop={scrollTop}
rowCount={Math.ceil(filtered.length / numColumns)}
rowHeight={ICON_CONTAINER_SIZE + 10}
rowRenderer={({ key, index: rowIndex, style }) => (
<div
key={key}
className="grid place-items-center"
style={{
...style,
gridTemplateColumns: `repeat(${numColumns}, 1fr)`,
}}
>
{Array.from(
{ length: numColumns },
(_, columnIndex) => {
const icon =
filtered[rowIndex * numColumns + columnIndex]
if (!icon) {
return null
}
return (
<IconItem name={icon.name} Icon={icon.Icon} />
)
}
)}
</div>
)}
/>
)}
</AutoSizer>
)}
</WindowScroller>
) : (
<Empty />
)}
</div>
</div>
)
}