Skip to content

tryangul/react-packery-component

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Packery Component

npm version

Introduction:

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

Support

React >= 0.14.x

Live demo:

hearsay.me

Installation:

$ npm install react-packery-component --save

Usage:

  • The component bundles Packery, so no additional dependencies needed!

  • You can optionally include Packery as a script tag if there should be any reason for doing so: <script src='//cdnjs.cloudflare.com/ajax/libs/packery/1.3.0/packery.pkgd.min.js' />

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

  • Example code:

var React = require('react');
var Packery = require('react-packery-component')(React);

var packeryOptions = {
    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 (
            <Packery
                className={'my-gallery-class'} // default ''
                elementType={'ul'} // default 'div'
                options={packeryOptions} // default {}
                disableImagesLoaded={false} // default false
            >
                {childElements}
            </Packery>
        );
    }
});

module.exports = Gallery;

About

A React.js component for using @desandro's Packery

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%