One level children

This commit is contained in:
Christopher Chedeau
2014-03-30 19:18:06 -07:00
parent 5ea06e888b
commit 8713562160
2 changed files with 38 additions and 5 deletions

View File

@@ -1,10 +1,28 @@
function computeLayout(node) {
return {
var top = 0;
var children = [];
(node.children || []).forEach(function(child) {
console.log(child);
children.push({
top: top,
left: 0,
width: child.style.width,
height: child.style.height
});
top += child.style.height;
});
var result = {
top: 0,
left: 0,
width: node.style.width,
height: node.style.height
};
if (children.length > 0) {
result.children = children;
}
return result;
}