0.0.26 • Published 2 years ago
react-responsive-virtual-grid v0.0.26
react-responsive-virtual-grid
💀🚟 Dead-simple react virtual grid library that act like a normal
<div>, checkout example
Install
npm install --save react-responsive-virtual-grid
# or
yarn add react-responsive-virtual-gridFeatures
- Responsive Grid (rows/columns)
- Virtual cells, render only when visible on the viewport
- Positioned visible cells with
position: absoluteandtransform: translate3d(x, y, 0) - Build with React
hooks, don't re-render if it's not necessary - Resize with the window
- Act like a normal
<div>with only definedheight
Usage
import React from 'react'
import VirtualGrid from 'react-responsive-virtual-grid'
const Item = ({ style, index, scrolling, readyInViewport }) => (
<div style={{ backgroundColor: 'gainsboro', ...style }}>
<img
src={`https://picsum.photos/id/${index}/304/160`}
alt={`Pcisum placeholder #${index}${scrolling ? ' - scrolling' : ''}${readyInViewport ? ' - readyInViewport' : ''}`}
style={{ objectFit: 'cover' }}
width='100%'
height='100%'
loading='lazy'
/>
</div>
)
const App = ({ ...props }) => (
<VirtualGrid
total={4000}
cell={{ height: 304, width: 160 }} // `width` is a `minWidth`, because the grid is reponsive (optional if you just want a list)
child={Item}
viewportOffset={10} // 5 on top, 5 on bottom
onRender={children => console.log(children)} // maybe useful callback
scrollDirection='vertical'
/>
)Checkout example/src/Apps.js for full example with header, footer, inside a div container with margin
License
MIT © thcolin
0.0.26
2 years ago
0.0.25
2 years ago
0.0.24
2 years ago
0.0.23
2 years ago
0.0.22
3 years ago
0.0.20
4 years ago
0.0.21
4 years ago
0.0.14
4 years ago
0.0.15
4 years ago
0.0.16
4 years ago
0.0.17
4 years ago
0.0.18
4 years ago
0.0.19
4 years ago
0.0.10
4 years ago
0.0.11
4 years ago
0.0.12
4 years ago
0.0.13
4 years ago
0.0.9
4 years ago
0.0.8
4 years ago
0.0.5
4 years ago
0.0.4
4 years ago
0.0.7
4 years ago
0.0.6
4 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago