make text with specific width work. plus a lot of hacks to manage dependencies. need to clean it up

This commit is contained in:
Christopher Chedeau
2014-04-26 12:46:21 -07:00
parent c06f48c45f
commit 8ca7bd0ccb
3 changed files with 60 additions and 25 deletions

View File

@@ -1,22 +1,6 @@
var computeLayout = (function() {
function fillNodes(node) {
node.layout = {
width: undefined,
height: undefined,
top: 0,
left: 0
};
if (!node.style) {
node.style = {};
}
if (!node.children) {
node.children = [];
}
node.children.forEach(fillNodes);
}
function extractNodes(node) {
var layout = node.layout;
delete node.layout;
@@ -231,9 +215,10 @@ var computeLayout = (function() {
node.layout[leading[crossAxis]] += getMargin(node, leading[crossAxis]) +
getRelativePosition(node, crossAxis);
if ('text' in node.style) {
node.layout.width = 36;
node.layout.height = 18;
if ('measure' in node.style) {
var dimensions = node.style.measure(node.style.width);
node.layout.width = dimensions.width;
node.layout.height = dimensions.height;
return;
}
@@ -464,7 +449,6 @@ var computeLayout = (function() {
}
var fn = function(node) {
fillNodes(node);
layoutNode(node);
return extractNodes(node);
};