All Projects → galkinrost → React Ingrid

galkinrost / React Ingrid

Licence: mit
React infinite grid

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Ingrid

vue-virtual-scroll-grid
A Vue 3 component that can render a list with 1000+ items as a grid in a performant way.
Stars: ✭ 64 (+8.47%)
Mutual labels:  grid, infinite-scroll
Reactables
GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems.
Stars: ✭ 112 (+89.83%)
Mutual labels:  grid, infinite-scroll
React Spreadsheet Grid
An Excel-like grid component for React with custom cell editors, performant scroll & resizable columns
Stars: ✭ 996 (+1588.14%)
Mutual labels:  grid
Magestudy
Magento 2 extension samples
Stars: ✭ 55 (-6.78%)
Mutual labels:  grid
Conway
A terminal interface for Conway's Game of Life
Stars: ✭ 47 (-20.34%)
Mutual labels:  grid
Flutter carousel slider
A flutter carousel widget, support infinite scroll, and custom child widget.
Stars: ✭ 998 (+1591.53%)
Mutual labels:  infinite-scroll
Lemon
🍋 Minimal and responsive CSS framework for fast building websites.
Stars: ✭ 51 (-13.56%)
Mutual labels:  grid
Fld Grd
Google Images/Flickr inspired fluid grid layouts
Stars: ✭ 37 (-37.29%)
Mutual labels:  grid
Glsl Grid
Draws an antialiased grid along the X/Y/Z direction of a mesh.
Stars: ✭ 57 (-3.39%)
Mutual labels:  grid
Practice
A clean timeline theme for the Ghost CMS
Stars: ✭ 46 (-22.03%)
Mutual labels:  infinite-scroll
Jscroll
An infinite scrolling plugin for jQuery.
Stars: ✭ 1,084 (+1737.29%)
Mutual labels:  infinite-scroll
Ngx Infinite Scroll
Infinite Scroll Directive for Angular
Stars: ✭ 1,024 (+1635.59%)
Mutual labels:  infinite-scroll
Cytoscape.js Grid Guide
A Cytsocape.js extension to provide a framework for grid interactions such as grid lines and snapping to grid, and guidelines and snap support for alignment of nodes.
Stars: ✭ 40 (-32.2%)
Mutual labels:  grid
Compoundbuttongroup
An Android library to easily implement compound buttons
Stars: ✭ 52 (-11.86%)
Mutual labels:  grid
Elastic Columns
A jQuery plugin designed to be used as an alternative to the well-known Isotope library.
Stars: ✭ 39 (-33.9%)
Mutual labels:  grid
React Bootstrap Table2
Next Generation of react-bootstrap-table
Stars: ✭ 1,090 (+1747.46%)
Mutual labels:  grid
Atgrid.css
CSS Grid System with attribute selectors
Stars: ✭ 37 (-37.29%)
Mutual labels:  grid
Masonry Layout
An efficient and fast web component that gives you a beautiful masonry layout
Stars: ✭ 43 (-27.12%)
Mutual labels:  grid
Fgci Ansible
🔬 Collection of the Finnish Grid and Cloud Infrastructure Ansible playbooks
Stars: ✭ 49 (-16.95%)
Mutual labels:  grid
Indoorjs
Indoor mapping for floorplans using on fabricjs
Stars: ✭ 59 (+0%)
Mutual labels:  grid

React Infinite Grid Build Status

Demo

Hint: Pay attention to the DOM.

Installation

npm install --save react-ingrid

Features

  • windowing - render only visible items
  • relative positioning - all items position relative each other
  • supports Immutable.js

Usage

import Ingrid from 'react-ingrid'

// Regular array or Immutable.js List
const items = [
    { id:1, foo: 'bar' },
    ...
]

// Your component must accept 'data' prop.
const ItemComponent = ({ data }) => (
    ...
)

const props = {
    ItemComponent,
    items,
    itemWidth: 100,
    itemHeight: 100,
    load: () => ( /* load more items */ ),
    more: Boolean, // has more
    loading: Boolean
}

...
<Ingrid {...props}/>

// or with decorator
import { ingrid } from 'react-ingrid'
const Grid = ingrid(props => props)(ItemComponent)

Props

ItemComponent (required)

Use your ✨imagination✨ to define how your grid items should look.

This component gets:

  • data - The data to render (plain object or Immutable.js)

It should return a react component. For example:

const ItemComponent = ({data}) => (
    <div>
        <h1>{data.title}</h1>
    </div>
)

items (required)

An array (or Immutable.js List) of items to display. For example:

const items = [
    {id:1, foo: 'bar'},
    ...
]

itemWidth & itemHeight (required)

ItemComponent's width and height.

For example, to render adaptive Ingrid (like with CSS media queries) you can do:

...

const [ itemWidth, itemHeight ] =
    windowWidth >= 320 && windowWidth < 376 ? [ 200, 200 ] :
    windowWidth >= 568 && windowWidth < 667 ? [ 300, 300 ] :
    windowWidth >= 1435 && windowWidth < 1445 ? [ 400, 400 ] :
    [ 500, 500 ]

const props = {
    ...
    ItemComponent: UserPhoto,
    itemWidth,
    itemHeight,
    ...
}

return (
    <Ingrid {...props} />
)

...

load (required)

Function that loads more items when user scrolls. Ingrid will call "load" every time user scrolls a page (unless you provide the more prop). You design how items are modelled. Therefore, it's your responsibility to load and sort items in your store.

more (optional, boolean)

Ingrid loads items when user scrolls. You must provide a boolean to tell whether you have more items to load.

By default, it is always true.

loading (required, boolean)

Normally you don't want to send multiple load requests at the same time. To tell Ingrid not to do it provide a boolean.

Also, you might want to show a preloader while loading new items. For example:

const ImagesGrid = ({ onLoadmore, loading }) => {
    const props = {
        ...
        load: () => onLoadmore(),
        loading,
        ...
    }

    return (
        <Ingrid {...props} />
    )
}

class App extends React.Component {
    ...
    render() {
        const { loading } = this.props
        return (
            {loading ?
                <ImagesGrid /> :
                this.renderLoadmoreSpinner()
            }
        )
    }
}

paddingTop (optional)

You might want to add extra padding on top. This is the best place to do it 😉

Note: Do not do it via CSS — Ingrid will not be able to calculate the top of the container, and everything will shake.

paddingLeft (optional)

The same is as the paddingTop but for the left side

getPaddingTop (optional)

This function is called when Ingrid is scrolled. It has the following signature:

function getPaddingTop(value)

where:

  • value - current paddingTop, if it > 0 or paddingTop prop then content was scrolled

You might want to use it to hide/show some element (hide a menu). For example:

const ImagesGrid = ({ handleGridScroll }) => {
    const props = {
        ...
        getPaddingTop: (value) => handleGridScroll(value),
        ...
    }

    return (
        <Ingrid {...props} />
    )
}

// ImagesActions.js
export const handleGridScroll = value => (dispatch, getState) => {
    const menuHeight = 300
    const { isMobile } = getState()

    if (isMobile && (value > menuHeight)) {
        dispatch({
            action: 'HIDE_MENU'
        })
    }
    if (isMobile && (value < menuHeight)) {
        dispatch({
            action: 'SHOW_MENU'
        })
    }
}

class App extends React.Component {
    ...
    render() {
        const { isShowingMenu } = this.props
        return (
            ...
            {isShowingMenu ?
                <Menu /> : ''
            }
            ...
        )
    }
}

isShowingPreloader (optional, boolean)

Ingrid shows a preloader while loading new items. We don't recommend to disable this behaviour. The better way is to create your own preloader and pass it through PreloaderComponent prop.

By default, it is true.

PreloaderComponent (optional)

If you don't happy with our default preloader use your ✨imagination✨ to implement your own.

const PreloaderComponent = () => (
    <div>
        <h1>Much loading. So wait.</h1>
    </div>
)

preloaderHeight (optional)

You can add more space for your preloader here.

shouldPrerenderAll (optional)

If you want to render your grid on the server side you should set this propery true. In this case all items will be rendered on the initial render call.

Examples

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].