diff --git a/package.json b/package.json index 00a9fb6..5d6d552 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte-grid-extended", - "version": "1.1.3", + "version": "1.1.4", "description": "A draggable and resizable grid layout, for Svelte", "repository": "https://github.com/cuire/svelte-grid-extended", "scripts": { diff --git a/src/lib/Grid.svelte b/src/lib/Grid.svelte index 1e1f404..123dab9 100644 --- a/src/lib/Grid.svelte +++ b/src/lib/Grid.svelte @@ -128,6 +128,24 @@ let shouldExpandCols = false; + let containerWidth: number | null = null; + + let containerHeight: number | null = null; + + // Check for colls / rows === 0 used to recalculate the grid container only if the grid is dynamic size + // #gh-48 + $: if ($gridSettings.itemSize && cols === 0) { + containerWidth = _cols * ($gridSettings.itemSize.width + gap + 1); + } else { + containerWidth = null; + } + + $: if ($gridSettings.itemSize && rows === 0) { + containerHeight = _rows * ($gridSettings.itemSize.height + gap + 1); + } else { + containerHeight = null; + } + $: if (typeof cols === 'number') _cols = cols; $: if (typeof rows === 'number') _rows = rows; @@ -236,7 +254,12 @@ setContext(GRID_CONTEXT_NAME, gridSettings); -