Comments (10)
@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.
from react-photo-gallery.
@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?
from react-photo-gallery.
Hmm sounds like maybe there was an API change that doesn't play nice with the previous version.
from react-photo-gallery.
@iMerica It's probably the new 'margin' property? although it shouldn't be... its broken at any browser width or a certain one?
from react-photo-gallery.
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
.
from 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.
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?
from react-photo-gallery.
Yep, using Chrome
from react-photo-gallery.
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:
- Add a warning to the README that the parent div can't have any margin 😃 .
- Offset the total combined width by the parent div's margin.
- Only apply a margin to the sides that are facing inwards (might be kinda tough)
from react-photo-gallery.
@iMerica hmm let me look into this. thanks.
from react-photo-gallery.
@iMerica i added both padding and margin to the Gallery's parent div and the div above that and did not see any problems.
from react-photo-gallery.
Related Issues (20)
- Lightbox image not centering HOT 3
- Adding attributes
- Handing images when they are missing
- Empty markup rendered using Jest and testing-library HOT 2
- React 17.x support HOT 6
- Rows Gallery Layout problem HOT 1
- Images become stretchy vertically on iPhone Safari HOT 6
- how to change number of image per row?
- How to load many images locally
- This Does not have support for react 17.0 HOT 2
- Additional props for photo
- Is is possible to cover images in gridview? HOT 1
- Caption, and hi-res download
- Add gap property to Gallery HOT 6
- How to add style to images?
- Custom dynamic columns example does not load
- Max image container width and height
- Defaultprops warning
- Can I use it with Angular?
- Update return type for `columns` function prop to `number | undefined`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-photo-gallery.