eiriklv / react-masonry-component

A React.js component for using @desandro's Masonry
MIT License
1.44k stars 145 forks source link

option horizontalOrder is missed #79

Closed rjohnep closed 7 years ago

rjohnep commented 7 years ago

Hi @eirikl, Can you update dependencies for 'masonry-layout' (4.2.0) and add 'horizontalOrder' option? Thanks.

nguymin4 commented 7 years ago

Hi @afram could you consider this? Thanks.

afram commented 7 years ago

@rjohnep @nguymin4 You can already do this.

The horizontalOrder property is a Masonry option, you can just add it to your existing Masonry options.

I have also added the option to the TypeScript interface and bumped the min version of masonry-layout to 4.2.0 - It shouldn't make a difference for you unless you are using TypeScript.

I'm going to close this issue. Please reopen if needed.

Here's an example on how you'd use horizontalOrder.

import React from 'react'
import Masonry from 'react-masonry-component';

const masonryOptions = {
    transitionDuration: 0,
    horizontalOrder: true
};

class Gallery extends React.Component {
    render() {
        const childElements = this.props.elements.map(function(element){
           return (
                <li className="image-element-class">
                    <img src={element.src} />
                </li>
            );
        });

        return (
            <Masonry options={masonryOptions}>
                {childElements}
            </Masonry>
        );
    }
};
afram commented 7 years ago

Should add that v5.0.7 has been released with the changes mentioned above.

johnantoni commented 5 years ago

Hi @afram, checked the latest release and doesn't appear to be there. Any chance of adding this in?