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

Automatically place item in grid

Open asjur opened this issue 3 years ago • 1 comments

I've been trying to find but is there a way to automatically lay out a set of items in the grid provided that you are specifying the size of each item? I'd like to avoid having to calculate positions if possible.

Edit: I found that fillSpace={true} with gridHelp.adjust can solve this issue somewhat. However I need to pass a column count, so I have gridHelp.adjust(items, 5) as 5 is the initial column size, however if the user comes from a mobile their column size is obviously different and it doesn't working. Can I get active column size somehow?

asjur avatar May 27 '21 08:05 asjur

you can get the current column by listening for the following events.. on:mount, on:resize, on:change

(event) => event.details.cols

https://github.com/vaheqelyan/svelte-grid/blob/master/www/src/routes/examples/responsive-local-storage.svx#L71 https://github.com/vaheqelyan/svelte-grid/blob/master/www/src/routes/examples/responsive-local-storage.svx#L20

vaheqelyan avatar May 30 '21 14:05 vaheqelyan