Open huy-vuong opened 3 years ago
Hi Huy, Have you solved this issue. I also want to increase the margin to 5, but when I use number larger than 2, the gallery breaks. Please let me know if you have any solution. Thank you
'Fraid not yet. =[ Hoping someone has an answer here.
'Fraid not yet. =[ Hoping someone has an answer here.
I just went through the source code, and found out you need to set margin on Gallery component as well. Problem solved, just set margin on both sections
const PHOTO_MARGIN = 5;
class MyGallery extends React.Component {
// ....
imageRenderer({ index, onClick, photo, margin, direction, top, left, key }) {
// const { history } = this.props;
// console.log(props)
return (
<div key={photo.id} className="image-div">
<Photo
key={photo.id}
index={index}
photo={photo}
left={left}
top={top}
onClick={() => {}}
margin={PHOTO_MARGIN}
direction={direction}
/>
</div>
);
}
render() {
return (
...
<Gallery photos={gallery_list} renderImage={this.imageRenderer} margin={PHOTO_MARGIN} />
...
)
}
}
Originally posted by @neptunian in https://github.com/neptunian/react-photo-gallery/issues/64#issuecomment-326077061
Is it possible to pass a desired margin to the library so instead of say
margin: 2px
it can calculate it assumingmargin: 1px
?