naver / egjs-infinitegrid

A module used to arrange card elements including content infinitely on a grid layout.
https://naver.github.io/egjs-infinitegrid/
MIT License
2.23k stars 95 forks source link

There are some questions about gap and itemSize #477

Closed Sirros closed 2 years ago

Sirros commented 2 years ago

The following content is from vue2

When I try to set the gap property to achieve consistent spacing per column, since I set the width of the items, the spacing per column is not what I want to see. So I tried setting the column property and removing the item's width css property and found that the image would get bigger.

I think when the user sets the column property, the width of each column should be calculated, the user does not need to design the width property for each item. When the window is resized, the size of each column changes accordingly.

So I wonder if my implementation is wrong or the framework doesn't support it?

image

image

image

image

daybrush commented 2 years ago

@Sirros

Maybe what you're talking about has something to do with align. The default value is "justify", and the column spacing can be increased to fill the screen.

If you want to center align, use "center".

Use "stretch" if you want to fill the screen and keep the column spacing as a gap.

Sirros commented 2 years ago

@daybrush I found that the layout of the first rendering is also wrong. When I drag the console border, the resize should be triggered, and the layout will be correct at this time.

image image

image image

daybrush commented 2 years ago

@Sirros

There is a high possibility that the size of the container will change during rendering.

If so, it is recommended to set the useResizeObserver option to true.

Sirros commented 2 years ago

@daybrush My settings are as follows, still having problems, maybe you can try to verify this problem. align="stretch" :gap="20" :column="column" :useResizeObserver="true"

image

daybrush commented 2 years ago

@Sirros

Because stretch was used, the height automatically increased as the width increased, but this was not detected.

https://github.com/naver/egjs-infinitegrid/issues/480 The observeChildren option will be added in this issue.

Sirros commented 2 years ago

@daybrush ok, looking forward~ Thanks for your patience

daybrush commented 2 years ago

@Sirros

InfiniteGrid 4.3.0 is released. use useResizeObserver and observeChildren to true. Thank you :)

Sirros commented 2 years ago

@daybrush thanks for solving