Closed iMerica closed 7 years ago
@iMerica i just did an npm install and ran the example app and it all seems to be working okay. does the example app work for you?
Hmm sounds like maybe there was an API change that doesn't play nice with the previous version.
@iMerica It's probably the new 'margin' property? although it shouldn't be... its broken at any browser width or a certain one?
I'm still debugging it, but it does appear to be a math problem with how the widths are now calculated.
Issue(s):
Case: Single photo Results: The image displays on about 1/3rd of the space available.
Case: 2 Photos, large/wide browser width: Results: The images display side by side, but do not take up the entire container width.
Case: 3+ photos Results: Images display erratically.
I think theres a mixed message being sent by the README and the Example app (or maybe I'm misreading something). The README tells me I can pass an array of photo objects that are of varying dimensions and react-photo-gallery
will figure out how to maintain the aspect ratio and use all the available space of the container to create a nice looking collage
The example app uses the measure component outside of react-photo-gallery
which tells me it's the user's responsibility to calculate the widths and columns, not the responsibility of react-photo-gallery
.
@iMerica yes it is now the user's responsibility to handle the columns. it defaults to 3 so if you dont pass in cols it should still work but always only have 3. This is because many people requested wanting to pass in their own # of cols and their own # of cols based on the width of the app, instead of me having it fixed and hardcoded in Gallery.js. You dont need to calculate the widths unless you want to, but yes, the col numbers will no longer change on their own.
https://github.com/neptunian/react-photo-gallery/issues/32
i did remove some extra margin that may have affected your app for some reason so ill look into that because none of these changes should break your images like that. Are you using Chrome?
Yep, using Chrome
@iMerica btw you are not actually calculating any widths. the Measure module is just what someone might want to use to detect the width of their own app and decide how many columns they want based on that width. the user can use whatever they want to figure this out, but i think the user should be able to control the # of cols based on whatever width they see fit. Gallery still calculates the photos given the cols or using the default cols value and width of the Gallery. what you're seeing should never occur.
I was able to workaround this bug by forcing the left/right margin of the parent div to be zero.
For example, my markup looks like this:
<div className="row">
<Gallery ... />
</div>
and the styles for row
(using Materialize, a popular CSS framework) were:
.container .row {
margin-left: -0.75rem;
margin-right: -0.75rem;
}
The previous version of react-photo-gallery played nice with parent divs having their own margin left/right, but this current version uses margin and doesn't factor in the margin that already exists of the parent div. The reason you don't see this on your example app is because you have no margin on your example app's parent div.
Possible fixes:
@iMerica hmm let me look into this. thanks.
@iMerica i added both padding and margin to the Gallery's parent div and the div above that and did not see any problems.
Issue
Hi Sandra,
I just upgraded from
5.0.2"
to^5.2.0"
on NPM and noticed that the grid is now broken.Here's what it looks like using random images on Unsplash.
After downgrading to
"react-photo-gallery": "5.0.2",
, the images look back to normal:Secondarily, the versions on Github don't sync with the versions on NPM making this issue a bit more difficult to bisect/debug.
Info
$ cat node_modules/react-photo-gallery/package.json | grep gitHead