Last active
April 8, 2020 23:03
-
-
Save clementbat/9d810a2ca9cdbfd86a5acd0b23e28ce3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function squarify (children, row, width) { | |
if (children.length === 1) { | |
layoutLastRow(row, children, width) | |
return | |
} | |
const rowWithChild = [...row, children[0]] | |
if (row.length === 0 || worst(row, width) >= worst(rowWithChild, width)) { | |
children.shift() | |
squarify(children, rowWithChild, width) | |
} else { | |
layoutRow(row, width) | |
squarify(children, [], getMinWidth().width) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment