MopTym / vue-waterfall

A waterfall layout component for Vue.js
MIT License
2.19k stars 260 forks source link

What should I specific the height parameter when I dont know the height of image? #17

Closed YuiZhou closed 7 years ago

YuiZhou commented 7 years ago

I have several images to show, which are in different size. I specific the image size like the following code, so that my image can auto resize.

img {
  width: 200px;
  height: auto;
}

However, the waterfall-slot needs to specific the width and height, I think noting all image's height and width is stupid and difficult in maintaining. So I just want to let the width is 200px, but the height is auto.

How should I specific the width and height parameter in this scenario?

alex4o commented 7 years ago

It is very important to know the aspect ratio of the images. This is how the algorithm determines how the layout the boxes. If you have a database you can store them there, or you could hardcode them. Or use something like this. Although I use the first approach.

YuiZhou commented 7 years ago

@alex4o thanks for your update, I comprehensive this point after looking into the code and some other introduction. 😄 And your suggestion link looks so interesting that it is worth a try 😃