support relative right and bottom

This commit is contained in:
Christopher Chedeau
2014-04-16 16:31:38 -07:00
parent 88f7e70abe
commit fb9534eed5
2 changed files with 29 additions and 2 deletions

View File

@@ -91,6 +91,15 @@ function computeLayout(node) {
return 0;
}
// If both left and right are defined, then use left. Otherwise return
// +left or -right depending on which is defined.
function getRelativePosition(node, axis) {
if (leading[axis] in node.style) {
return getPosition(node, leading[axis]);
}
return -getPosition(node, trailing[axis]);
}
var axis = {
left: 'horizontal',
right: 'horizontal',
@@ -224,9 +233,9 @@ function computeLayout(node) {
});
node.layout[leading[mainAxis]] += getMargin(node, leading[mainAxis]) +
getPosition(node, leading[mainAxis]);
getRelativePosition(node, mainAxis);
node.layout[leading[crossAxis]] += getMargin(node, leading[crossAxis]) +
getPosition(node, leading[crossAxis]);
getRelativePosition(node, crossAxis);
}
fillNodes(node);