Giter Site home page Giter Site logo

Comments (10)

neptunian avatar neptunian commented on June 12, 2024 1

@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.

neptunian avatar neptunian commented on June 12, 2024

@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.

iMerica avatar iMerica commented on June 12, 2024

Hmm sounds like maybe there was an API change that doesn't play nice with the previous version.

from react-photo-gallery.

neptunian avatar neptunian commented on June 12, 2024

@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.

iMerica avatar iMerica commented on June 12, 2024

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.

neptunian avatar neptunian commented on June 12, 2024

@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.

#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?

from react-photo-gallery.

iMerica avatar iMerica commented on June 12, 2024

Yep, using Chrome

from react-photo-gallery.

iMerica avatar iMerica commented on June 12, 2024

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.

neptunian avatar neptunian commented on June 12, 2024

@iMerica hmm let me look into this. thanks.

from react-photo-gallery.

neptunian avatar neptunian commented on June 12, 2024

@iMerica i added both padding and margin to the Gallery's parent div and the div above that and did not see any problems.

screen shot 2017-03-13 at 9 55 08 am

from react-photo-gallery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.