Fix issue with layout determination
This commit is contained in:
parent
d4a767f93e
commit
5beb6819ec
|
@ -117,19 +117,22 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
// Calculate the variance between each set of positions on the children
|
// Calculate the variance between each set of positions on the children
|
||||||
const variances = Object.keys(childCoords[0]).map(key => {
|
const variances = Object.keys(childCoords[0])
|
||||||
const coords = childCoords.map(x => x[key])
|
.filter(x => x !== "placeholder")
|
||||||
return {
|
.map(key => {
|
||||||
variance: variance(coords),
|
const coords = childCoords.map(x => x[key])
|
||||||
side: key,
|
return {
|
||||||
}
|
variance: variance(coords),
|
||||||
})
|
side: key,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Sort by variance. The lowest variance position indicates whether we are
|
// Sort by variance. The lowest variance position indicates whether we are
|
||||||
// in a row or column layout
|
// in a row or column layout
|
||||||
variances.sort((a, b) => {
|
variances.sort((a, b) => {
|
||||||
return a.variance < b.variance ? -1 : 1
|
return a.variance < b.variance ? -1 : 1
|
||||||
})
|
})
|
||||||
|
console.log(variances[0].side)
|
||||||
const column = ["centerX", "left", "right"].includes(variances[0].side)
|
const column = ["centerX", "left", "right"].includes(variances[0].side)
|
||||||
console.log(column ? "COL" : "ROW")
|
console.log(column ? "COL" : "ROW")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue