eiriklv / react-masonry-component

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

Position left to all elements is 0 when first element is wider than other #68

Closed DmitryTurovtsov closed 7 years ago

DmitryTurovtsov commented 7 years ago

Everything the same except position of wide element in array. Masonry is initialized but work incorrect. All elements have position-left 0...

2017-02-01 22 16 28 2017-02-01 22 15 18

Hope for quick reply. tnx)

afram commented 7 years ago

Hi @DimaNodeJs

Which version of react-masonry-component are you using?

Still at work right now, will do my best to look at this tonight with you.

afram commented 7 years ago

Can you please paste up a simple reproduction of this issue on WebpackBin?

http://www.webpackbin.com/

DmitryTurovtsov commented 7 years ago

@afram "version": "5.0.3"

import React from 'react';
import GridItem from './item';
import classnames from 'classnames';
import Masonry from 'react-masonry-component';

const Grid = ({ items, masonry }) => {
  const masonryOptions = {
    transitionDuration: '0.6s'
  };

  if (items.length) { items = items.map(GridItem) }

  return (
    <div className={classnames('b-grid', {[`b-grid--masonry`]: masonry})} >
      { masonry ? <Masonry options={masonryOptions} >{ items }</Masonry> : items }
    </div>
  )
};

export default Grid;

Could it be helpful? it's almost exactly the same code I use. Mb you can find something strange in it and it's not an issue at all)) If not I'll create an example later in several hours.

DmitryTurovtsov commented 7 years ago

I think I had to set columnWidth property equal to smaller item. But there is no information about it in docs(( btw thx for really quick reply and aspiration to help! )

afram commented 7 years ago

no problem. columnWidth would be from Masonry's side. Can I close this now as resolved?

afram commented 7 years ago

closing. Please reopen if needed.