svelte-grid
svelte-grid copied to clipboard
Automatically place item in grid
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?
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