egjs-grid icon indicating copy to clipboard operation
egjs-grid copied to clipboard

bug: the gap not work

Open liuJchun opened this issue 1 year ago • 13 comments

Description

this is a bug? desc: the gap now work when loading,only work when loaded completely image image

Steps to check or reproduce

use @egjs/react-grid package will show this problem

liuJchun avatar Mar 29 '23 10:03 liuJchun

@liuJchun

Probably because batching doesn't happen while loading The following phenomena may occur.

Try to set data-grid-lazy="true" on item element?

daybrush avatar Mar 30 '23 07:03 daybrush

Hi, I'm encountering an issue with columns in which one of the columns with a percentage width doesn't have enough space to fill out its spot when the gap option is set.

Here's a pen.

stepanjakl avatar Apr 19 '23 20:04 stepanjakl

@stepanjakl

align: 'justify', independent of gap.

If so, change it to align: "center", "start", "end".

daybrush avatar May 09 '23 01:05 daybrush

Hi @daybrush, even if I align the columns differently, the layout is not correct. There should be 3 columns instead of 2 as each column has width of 33.333%. Please see the example in the previous message. Preferably, the script should take column width into consideration when calculating the gap?

stepanjakl avatar May 09 '23 09:05 stepanjakl

@stepanjakl

33.333%, so the sum of the three is 100%. Therefore, it is difficult to set the gap to 30 (set 0).

daybrush avatar May 09 '23 10:05 daybrush

Yes, but if I set gap to 0 then there'll be no gap between the columns. I was hoping the script would calculate the gap taking column width into consideration. Does it make sense?

stepanjakl avatar May 09 '23 10:05 stepanjakl

I did sort it out this way btw:

<div class="w-full md:w-[calc(50%-(1rem/2))] lg:w-[calc(33.333333%-(1rem/(3/2)))]{% if loop.index === 1 %} lg:pt-40{% elseif loop.index === 3 %} lg:pt-20{% endif %}">

But this is not an ideal solution. The grid library should ideally compute the gap without me adjusting the column width.

stepanjakl avatar May 09 '23 10:05 stepanjakl

@stepanjakl

It can't be helped because you set the width yourself.

If you expect to automatically change the width, try setting it with the following option. Instead, you must input the column value directly.

columns: 3,
gap: 30;
align: "stretch",

daybrush avatar May 09 '23 10:05 daybrush

Okay, I tried it, but it's overflowing its parent container now. Moreover, is there a way to set column breakpoints for different viewport widths?

Screenshot 2023-05-09 at 11 53 04

stepanjakl avatar May 09 '23 10:05 stepanjakl

@stepanjakl

image

Try modifying align to "stretch".

daybrush avatar May 09 '23 11:05 daybrush

Ouh nice, that works, thanks! :)

One more question, how to handle responsivity when it comes number of columns or gap width?

stepanjakl avatar May 09 '23 11:05 stepanjakl

@stepanjakl

Modify the column value directly through resize event or resizeObserver.

grid.column = 2 ~ 4

daybrush avatar May 09 '23 12:05 daybrush

Awesome, thank you. It's great library in any case.

stepanjakl avatar May 09 '23 12:05 stepanjakl