bmcmahen / react-gesture-gallery

a react image gallery with gesture support
https://codesandbox.io/embed/react-gesture-gallery-dup51
13 stars 1 forks source link

BreadCrumb Overflow #4

Closed JuanMugicaExt closed 5 years ago

JuanMugicaExt commented 5 years ago

Hey bmc,

First off love the component, simple and easy to use, but when dealing with a large number of images, especially when rendering the gallery in a modal window, it's easy for the breadcrumbs to overflow the dimensions of their container. Would there be any interest in looking for a solution to this? thoughts? Cheers!

bmcmahen commented 5 years ago

That's a great point. I hadn't really considered that scenario. I'm definitely interested in a potential solution - i suppose the breadcrumbs could be limited to a max-width and then cycle into view. Hmm. Any ideas yourself?

bmcmahen commented 5 years ago

I guess the easiest solution for now would be to just disable them as it might not make a ton of sense within the context of a very long series of images anyway.

JuanMugicaExt commented 5 years ago

The way i was able to sort it out was just by adding an arbitrary number x and then making the breadcrumb length Math.min(children.length,x), and the index input (index%x). This way if the array is ever shorter than our desired breadcrumb max it will display the shorter one. (Index%x) makes sure that when we exceed our breadcrumb max in index it will come back to the first breadcrumb! Worked like a charm and should be rather simple to implement. Once again wanted to give Kudos to the simplicity and usability of this gallery module.

JuanMugicaExt commented 5 years ago

Also for usability purposes x could be set to an int.max at first so if it is not passed as a parameter the user will never have to worry about it for simpler implementations of the gallery. This way Math.min will always choose children length and index%x will always be index.

bmcmahen commented 5 years ago

that's a clever solution... not sure if it's something i'd want to bake into this component, but def might be worth noting in the readme.