react-masonry-component-4meteorhacks-npm

0.0.13 • Public • Published

React Masonry Component

npm version

Introduction:

A React.js Masonry component. (Also available as a mixin if needed)

Live demo:

hearsay.me

Usage:

  • The component is bundled with Masonry, so no additional dependencies needed!

  • You can optionally include Masonry as a script tag if the should be any reason for doing so <script src='//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.5/masonry.pkgd.min.js' />

  • To use the component just require the module and inject React

  • example code

var React = require('react');
var Masonry = require('react-masonry-component')(React);
 
var masonryOptions = {
    transitionDuration: 0
};
 
var Gallery = React.createClass({
    render: function () {
        var childElements = this.props.elements.map(function(element){
           return (
                <li className="image-element-class">
                    <img src={element.src} />
                </li>
            );
        });
        
        return (
            <Masonry
                className={'my-gallery-class'} // default ''
                elementType={'ul'} // default 'div'
                options={masonryOptions} // default {}
                disableImagesLoaded={false} // default false
            >
                {childElements}
            </Masonry>
        );
    }
});
 
module.exports = Gallery;

/react-masonry-component-4meteorhacks-npm/

    Package Sidebar

    Install

    npm i react-masonry-component-4meteorhacks-npm

    Weekly Downloads

    6

    Version

    0.0.13

    License

    MIT

    Last publish

    Collaborators

    • puruzio