From cb6a13fafd431cc4fee5298d5492c38a8bcc2b5f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 7 Oct 2022 12:45:22 +0100 Subject: [PATCH] Fix issue with layout determination --- .../src/components/preview/DNDHandler.svelte | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/client/src/components/preview/DNDHandler.svelte b/packages/client/src/components/preview/DNDHandler.svelte index 50ea287a9b..f7783990a5 100644 --- a/packages/client/src/components/preview/DNDHandler.svelte +++ b/packages/client/src/components/preview/DNDHandler.svelte @@ -117,19 +117,22 @@ }) // Calculate the variance between each set of positions on the children - const variances = Object.keys(childCoords[0]).map(key => { - const coords = childCoords.map(x => x[key]) - return { - variance: variance(coords), - side: key, - } - }) + const variances = Object.keys(childCoords[0]) + .filter(x => x !== "placeholder") + .map(key => { + const coords = childCoords.map(x => x[key]) + return { + variance: variance(coords), + side: key, + } + }) // Sort by variance. The lowest variance position indicates whether we are // in a row or column layout variances.sort((a, b) => { return a.variance < b.variance ? -1 : 1 }) + console.log(variances[0].side) const column = ["centerX", "left", "right"].includes(variances[0].side) console.log(column ? "COL" : "ROW")