1.2.4 • Published 6 years ago

yundo-react-masonry-infinite v1.2.4

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

React Masonry Infinite

Very simple React.js component for masonry grid. Based on Bricks.js, React Infinite Scroller and React Masonry Layout.

Component is mostly suitable for static data, but can be used with dynamic with instance methods.

Demo

Demo page

Features

Instalation

Using NPM

  npm install --save react-masonry-infinite

Using yarn

  yarn add react-masonry-infinite

Basic example

import MasonryInfiniteScroller from 'react-masonry-infinite';

...
<MasonryInfiniteScroller hasMore={this.state.hasMore} loadMore={() => this.setState({ elements: this.state.elements.push("Element") })}>
    {
        this.state.elements.map((el, index) =>
            <div key={index}/>
        )
    }
</MasonryInfiniteScroller>
...

Props

PropsTypeDefaultDescription
classNameString''CSS className for root element
packBooleanfalseFlag to force pack on every update
packedStringdata-packedAn attribute added to the grid items after they're positioned within the grid. If the attribute is not prefixed with data-, it will be added. See Bricks.js
sizesArray[{ columns: 1, gutter: 20 }, { mq: '768px', columns: 2, gutter: 20 }, { mq: '1024px', columns: 3, gutter: 20 }]An array of objects describing the grid's properties at different breakpoints. When defining your sizes, note the rules of Bricks.js
positionBooleantrueA Booleanean indicating that the grid items should be positioned using the top and left CSS properties.
styleObject{}The inline style
pageStartNumber0The page number corresponding to the initial items, defaults to 0 which means that for the first loading, loadMore will be called with 1
loadMoreFunction(pageToLoad) => {}This function is called when the user scrolls down and we need to load items
hasMoreBooleantrueBooleanean stating whether there are more items to be loaded. Event listeners are removed if false
loaderDOMNodenullLoader element to be displayed while loading items
thresholdNumber250The distance between the bottom of the page and the bottom of the window's viewport that triggers the loading of new items
useWindowDOMNodenullBooleanean stating whether to add listeners to the window, or else, the DOMNode
elementStringdivElement type of infinite scroll container

Methods

MethodDescription
forcePackPacks Bricks.js instance (usefull when data is dynamic)
forceUpdateUpdates Bricks.js instance

License

MIT